Install Any Version of Ruby on Mac OSX with Homebrew

With the recent release of Ruby 3.0, I thought it’d be a good idea to make my first post of the year on a quick how-to guide to installing the new (or any) version of Ruby.


Homebrew

The only thing you’ll need before we get started is brew installed on your machine.

If you don’t have brew, install it by running the following command:

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"



Ruby Install

Once you have brew, you’re ready to go! First, we must install a tool Postmodern/ruby-install to get the version of Ruby that we want:

$ brew install ruby-install

Now we can download and install any version of ruby available. If we want Ruby 3.0:

$ ruby-install ruby-3.0

or for latest version:

$ ruby-install --latest


Voila! You can now install any version of Ruby you choose.

Multiple Versions of Ruby

If you need to utilize multiple versions of Ruby and will need to switch back and forth between versions, you may use the corresponding chruby tool here Postmodern/chruby.

$ brew install chruby

Then, to switch between versions:

$ chruby [VERSION]

Leave a Reply

Your email address will not be published. Required fields are marked *