When managing multiple versions of Ruby on Mac, you have two options, rvm and rbenv. I prefer the simplicity ad straightforwardness of rbenv, so this article will focus on the basics of installing Ruby and Rails. If you'd like to research the two package managers further, check out the appendix below.

If you'd rather use rvm instead, here is my tutorial on how to do it.


Step 0 - Install brew for Mac

Homebrew is a package manager for stuff other than Ruby or Rails. You'll need this to install rbenv.

Install Homebrew

Step 1 - Install rbenv to manage Ruby

Install rbenv

brew install rbenv

Step 2 - Pick and Install Ruby

Install a stable version of Ruby that rbenv supports.

 rbenv install --list

View all available versions of Ruby and filter them by a specific version.

 rbenv install --list-all | grep 3
rbenv install <ENTER YOUR VERSION NUMBER HERE>

Configure your environmental variables to always use rbenv upon load. Open up Terminal and paste this line of code.

echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

Refresh your Terminal.

source ~/.bash_profile 

Double-check that rbenv is installed and working as expected.

which rbenv

Double check your installation of rbenv

Standing on the shoulders of giants

Install whichever ruby version you need. One trick is to look at what version Heroku supports and copy them.

rbenv install 2.x.x

Every time you install something, you need to rehash

rbenv rehash

Switch your computer to start using Ruby 2.x.x

rbenv global 2.x.x

Step 3 - Update gem

If you're on Mac OS X, you need to update gem.

gem update --system

Step 4 - Install bundler gem

Bundler is a package manager added to Rails 3 to keep things organized.

gem install bundler

Remember that every time you install something, you need to rehash it.

rbenv rehash

Step 5 - Install rails

Install Rails and skip the documentation to speed up the installation. If you're not sure which version of Rails to pick, try looking at Heroku's package or OpenShift's cartridge.

This command looks slightly different from what you'll often see in books or Stackoverflow. It's the most reliable way to install the precise version of Rails you want.

RBENV_VERSION=2.x.x rbenv exec gem install rails --version 5.2.3 --no-document
rbenv rehash

Step 6 - Install a database

Install a database using Homebrew


Step 7 - Pick an IDE

  • Textmate is lightweight, capable of handling ruby, rails, javascript, HTML, erb, jade, and pretty much anything else you throw at it.
  • RubyMine is fantastic if you're familiar with IntelliJ or PyCharm. brew cask install rubymine
  • RadRails is suitable for developers familiar with Eclipse.

Resources