How to install Ruby on Mac

Hugh Greethead
Hugh Greethead
Published in
2 min readMar 3, 2020

For the majority of MacOS users they are lucky that the device comes pre-installed with Ruby. However when programming there are many times when we might want to switch between different devices or customise our setup further. This is where installing Ruby with a version manager, such as RVM becomes useful to us.

The following details the basic procedure to install Ruby using RVM:

1. Setup terminal

If you haven’t already customised your terminal I recommend you read my article: How to customise your Mac terminal with ZSH and PowerLevel10k to install a more aesthetic and functional shell setup.

2. Install Ruby Version Manager — RVM. RVM is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems. You could also use rbenv instead however I find the RVM commands and documentation to be easier to use.

Following the instructions on the website, enter the commands:

gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

Then

\curl -sSL https://get.rvm.io | bash -s stable --rails

3. Integrate zsh +iTerm
Assuming you have setup zsh in earlier steps, integrate zsh + iTerm with the steps outlined here: https://rvm.io/integration/zsh#zsh-iterm

4. Install Ruby
Enter the following into the command line:

rvm install "ruby-2.7.0"

or this will also work

rvm install 2.7.0

Once installed, you can use the following command to check which version of Ruby you are running:

ruby -v

5. Using different versions of Ruby

There may be times when an older version of Ruby. First make sure it is installed and then use the following command to switch to that version:

rvm use <version_number>

You can also set the default Ruby version. I set my default to version 2.7.0.

rvm --default use 2.7.0

And that’s all there is to it. Let me know if this guide helped you or if you have any other methods you use to install Ruby.

-Hugh

I am a junior developer in training at CoderAcademy in Sydney, Australia. My interests are in programming, economics, trading and Bitcoin. Follow me on Twitter @hughgreethead

--

--