Installing chruby

Next up install chruby according to instructions. I installed it using homebrew.

$ brew install chruby

If you’re keeping your old ruby installations then refer to the migrating instructions. I wasn’t so all I have to do is add the following lines to my shell startup script, ~/.zshrc.

source /usr/local/opt/chruby/share/chruby/chruby.sh

source /usr/local/opt/chruby/share/chruby/auto.sh

Note that the second line is optional and only needed if you use .ruby-version files, which I do. Then activate chruby.

$ source ~/.zshrc

I added a .ruby-version in my home directory to tell chruby to use the version I just installed

$ echo "ruby-2.3.0" > ~/.ruby-version

Then run ruby -v to confirm it worked.

$ ruby -v

ruby 2.3.0p0 (2015–12–25 revision 53290) [x86_64-darwin15]

For existing projects all that is needed is to install the ruby version required and use .ruby-version to tell chruby to use it. You’ll need to reinstall any gems as well. I did this for a rails project running ruby 2.2.3.