Installing the most recent version of Ruby on Snow Leopard

Solution 1:

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

Solution 2:

What do you mean by "get the new Ruby into place"?

If you are trying to run it from the command line using just the command ruby, the system will search each of the paths specified in /etc/paths in order until it finds a match. In Snow Leopard, the default /etc/paths file looks like this:

/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin

So when you enter ruby at the command line, the system looks for /usr/bin/ruby first, finds it, and doesn't check the rest of the paths (so it never gets to /usr/local/bin/ruby). To confirm this, you can enter which ruby at the command line, and the system will print the path of the executable that it would use for that command.

If you want to run your newer version of Ruby from the command line, simply enter /usr/local/bin/ruby instead of ruby.

If you are using another program that is using Ruby indirectly, there's probably an option somewhere to specify the path to ruby.


EDIT: As a last resort, you can overwrite the built-in system version of Ruby with your newer version. Use the following commands, and enter your administrator password when prompted:

cp /usr/bin/ruby ~/Desktop/ruby_OLD
sudo cp /usr/local/bin/ruby /usr/bin/ruby

If something breaks, put it back with this command:

sudo mv ~/Desktop/ruby_OLD /usr/bin/ruby

As others have mentioned, though, using a tool like RVM to manage Ruby would be a better idea than upgrading the built-in installation.

Solution 3:

The way to get any self installed program to be found before an Apple supplied ome is to add the directory of the new program (e.g. /usr/local/bin) to the fromt of the PATH environment variable.

If you are running ruby from the shell edit ~/.profile or if from a GUI ~/.MacOSX/environment.plist