Installing the most recent version of Ruby on Snow Leopard

softwareterminal

I downloaded and compiled the latest version of ruby 1.9.2 which was installed in /usr/local/bin/ruby, however the system officially recognizes /usr/bin/ruby which is only 1.8.7 which came installed on the machine. How can I get the new ruby into place?

In this instance I need to replace the ruby version and be able to use the updated version for command line work and rails development.

Best Answer

You should use RVM, the Ruby Version Manager. It allows multiple side-by-side installations of Ruby without affecting the system Ruby installation, which as another commenter pointed out can potentially be problematic (or at the very least, tiresome to maintain).

It allows you to quickly and easily install the latest patchlevel of Ruby, past Ruby versions, or even alternate implementations like JRuby, MacRuby, or Rubinius.

To install:

$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

Once it's installed, setting 1.9.2 as the default is as simple as typing:

rvm default 1.9.2

And if you feel like switching back to 1.8.7 temporarily:

rvm use 1.8.7