Ruby Day 1 — Set up rbenv and Simple Rails

Sasikate Suwanchatree
3 min readJun 5, 2021

--

Back to code. Note for me, maybe help someone else.

Ruby on Rails

I have written this article since March 2020 when I was unemployed by the impact of the Covid Crisis.

After that I got jobs and had a long marathon working as a Product Manager, so today in June 2021, I want to back to code and relax my thought.

I found what I wrote since last year, still useful for me now.
So I want to finish this article.

Start ….

☑️ macOS → I use iTerm2 Terminal tool (why? check here! )

☑️ iTerm2 + zsh (you can use bash instead of zsh) to install all you need for coding.

☑️ Installed brew
I did it a long time ago so I just check the update;

$ brew update
$ brew doctor

☑️ Install rbenv

rbevn lets you install and run multiple versions of Ruby side-by-side

$ brew install rbenv( or $ brew upgrade rbenv ruby-build )

❌ I got “Error: The following directories are not writable by your user: /usr/local/Frameworks” — → but I didn’t do as it suggested. I solve it by

$ sudo mkdir /usr/local/Frameworks
$ sudo chown $(whoami):admin /usr/local/Frameworks

☑️ Set up rbenv, some steps to do 😊

# 1: Set up rbenv in your shell.
$ rbenv init
# 2: Add path rbenv and enable shims and auto-complete on ~/.zshrc (or ~/.bashrc #if you use bash)
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
$ echo 'eval "$(rbenv init -)"' >> ~/.zshrc
# 3: Apply the change to shell
$ source ~/.zshrc
# 4: Ensure it works.
$ which ruby
(It should shows /Users/<username>/.rbenv/shims/ruby)
# 5(optional): Check rbenv is working using rbenv-doctor (same for both zsh and bash)
$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash
# 6: List all available versions
$ rbenv install -l
# 7: Install Ruby versions (I installed 2 versions)
$ rbenv install 2.7.3
$ rbenv install 3.0.1
# 8: Make the default for the system
$ rbenv global 3.0.1
# 9: Check Ruby version of the system, it should be ruby 3.0.1p64 ..
$ ruby -v

( If your rbenv global doesn’t work, check here it works!)

☑️ So now you are ready to code Ruby

❗️But … on my old laptop, it already had RVM which I already forgot. It causes some errors and I spent a few hours finding the solutions. Last year, I already published the solutions here.

RBENV: Cannot install some ruby versions — Error: unknown type name ‘lzma_bool’.

RBENV: Working tree error when rbenv install some ruby versions on macOS Catalina.

☑️ Let’s start the first Tiny ruby project.
Switch ruby version for your local environment;
I have rbenv install Ruby on a few versions.

$ rbenv versions
# It shows all 2 versions I installed
2.7.3
3.0.1

I will select the local environment to be ruby version 3.0.1

$ rbenv local 3.0.1
$ rbenv version
# It shows the version is using

☑️ Installed Rails

# Set no documents when install any ruby package
$ echo "gem: --no-document" > ~/.gemrc
# Install bundler
$ sudo gem install bundler
# Install Rails
$ gem install rails
# To apply what you just installed.
$ rbenv rehash
# Check Rails version (My version is Rails 6.1.3.2 )
$ rails -v

☑️ After this, I will create a new web application with rails, by following the step here, it works.

Tada! I’m on Rails.

I will continue the next story on Ruby Day 2 — VS Code and Rails.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Sasikate Suwanchatree
Sasikate Suwanchatree

Written by Sasikate Suwanchatree

Technical Product Management 🌱 Currently Building Cutting-Edge AI Solutions

No responses yet

Write a response