I recently re-installed Ruby and Rails to start playing with it again. This time when I went to rubyonrails.org to check what was the latest version of Ruby and Rails, I noticed they were not recommending the traditional RVM to manage the Ruby installation anymore, but they were recommending something called rbenv. So I tried it.
Although rbenv has a lengthy documentation page on its GitHub page, the instructions to install Ruby and then Rails where not 100% complete and I had to look for extra information on Stack Overflow and other sites.
Here’s a step by step to install rbenv, Ruby and then Rails on OS X Yosemite.
- Install Homebrew, the package manager for OS X. Paste the following at a Terminal prompt:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Now that Homebrew is installed, run the following:
$ brew update $ brew install rbenv ruby-build
- You can now list all the available Ruby version and check the one you want to install:
$ rbenv install -l
- Let’s install Ruby version 2.2.2 (or whatever version you want):
$ rbenv install 2.2.2
- If you check your Ruby version now ($ ruby -v) you will still see the existing system Ruby version and not the one you just installed. To fix that, run the following commands to make sure rbenv is in your PATH:
$ export PATH="$HOME/.rbenv/bin:$PATH" $ eval "$(rbenv init -)" $env | grep PATH
- Now that we have rbenv and Ruby installed, let’s install Rails:
gem install rails
- Rails is now installed, but in order for us to use the
railsexecutable, we need to tell
rbenvto see it:
- And now we can verify Rails is installed:
With that, you should be all set up with your new Ruby on Rails installation.
If you have any questions about any of the steps, just let me know!