Sometimes you’ll need different versions of Ruby for different projects.
chruby allows you to have multiple versions at once and choose which one to use at any given time. This tutorial will assume you are on a mac (sorry Linux and Windows users). First install
brew install chruby --HEAD
brew install ruby-install --HEAD
Then install the needed version of Ruby. Let’s assume you need 2.3.1.
ruby-install ruby 2.3.1
Now change to that version of Ruby. If you use the command
chruby you won’t see the new version in the list of versions you have until you restart your shell. So let’s restart your shell to refresh your list of Ruby versions displayed by chruby.
exec bash -l
Now if you use
chruby you will see the version you just downloaded. So now you can switch to that version.
But your gems will still be on the old version. Let’s get the gems for the new version.
gem install bundler
Now let’s install the gems for 2.3.1.
And that’s it. You should be all set with your new version of Ruby. If you want to change back to another version of Ruby that you have installed you should not have to repeat the