When managing multiple versions of Ruby on Mac, you have two options,
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
Step 1 - Install
rbenv to manage Ruby
brew install rbenv
Step 2 - Pick and Install Ruby
Install a stable version of Ruby that
rbenv install --list
View all available versions of Ruby and filter them by a specific version.
rbenv install --list-all | grep 3
brew 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.
rbenv is installed and working as expected.
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
Switch your computer to start using Ruby 2.x.x
rbenv global 2.x.x
Step 3 - Update
If you're on Mac OS X, you need to update
gem update --system
Step 4 - Install
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.
Step 5 - Install
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
Step 6 - Install a database
Step 7 - Pick an IDE
- RubyMine is fantastic if you're familiar with IntelliJ or PyCharm.
brew cask install rubymine
- RadRails is suitable for developers familiar with Eclipse.