1 RVM

What you might be interested to know is that Ruby comes preinstalled on your Mac. Don't believe me? Open the Terminal and type:

ruby -v
1

Likely, the version number will return 1.8.7. While you might be tempted to stick with that, you probably shouldn't for a couple reasons:

  • Old versions of the OS shipped with a buggy version of Ruby
  • RVM provides the flexibility to use any version of Ruby that you require. Plus, if you're just starting out with Ruby, don't use an old version; you want 2.4.1!

These days, RVMopen in new window is the way the cool guys install Ruby, and that's what we'll use.

Open the Terminal, and type:

$ \curl -L https://get.rvm.io | bash -s stable --rails --autolibs=enabled
1
Notes

If an error is returned when you run this command, make sure that you have Git installedopen in new window.

2 Load RVM into the Shell

Give that a few seconds to install, and next, we need to make RVM available to the shell. We'll do this by updating our ~/.bash_profile file.

cd ~/
sudo subl .bash_profile
1
2

Note that we're using Sublime to update this file. Feel free to open this file in any code editor your prefer. Also, note that, if this file does not exist, you should create it manually. Paste the following to the bottom of the page.

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.
1

If you're using Vim, you'll need to press i to switch into Insert Mode first. Once the line has been pasted, press Escape, and then :wq! to save and close the file. If you're using a different code editor, then you know what to do!

3 Restart Terminal

Just to be safe, let's restart Terminal to make sure that everything took effect. To ensure that RVM is correctly installed, type:

rvm
1

You should see a long list of commands that are available to you.

4 Download Ruby

Next, restart Terminal, and type:

rvm list known
1

You'll see a long list of versions...

Sergeys-MacBook-Pro:~ sergeydegtyar$ rvm list known
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.7]
[ruby-]2.3[.4]
[ruby-]2.4[.1]
ruby-head
1
2
3
4
5
6
7
8
9
10
11
12
13

For our needs, let's install Ruby 2.4.1

rvm install 2.4.1
1

That shouldn't take but a moment.

Once the installation has completed, we need to tell RVM which version of Ruby we currently want to use:

rvm use 2.4.1
1

Next, test it by checking the version number:

ruby -v
1

5 Make 2.4.1 the Default

If you restart Terminal, and type ruby -v again, you'll likely find that it has defaulted back to the system version of Ruby: 1.8.7. That's no good! Let's be sure to make 2.4.1 the default.

rvm --default use 2.4.1
1

This bit is identical to what we did just a moment ago - the only difference being that we've specified that 2.4.1 should be the default.