Thursday, February 10, 2011

Upgrading Ruby on FreeBSD

The Ruby language has fairly frequent bugfixes and minor release versions. Keeping up with this can be challenging, but with RVM (Ruby Version Manager) it's pretty much a snap.

Today I upgraded my Ruby installation on FreeBSD from 1.9.2-p0 to 1.9.2-p136, with a pretty substantial number of fixes added from one version to the other.

On FreeBSD, you should avoid using the Ruby ports altogether, and let the wonderful little RVM shell script manage your installation. It will save hours of messing around with the Ruby and Gems ports, which don't play well with Rails :-(

RVM has a real talent for managing multiple installed Ruby/Gems installations - all in a hidden .rvm directory in your home directory. It requires no root privileges to use. It also updates itself with ease and appears to have a very dedicated author. If you don't already have RVM installed, you can get it from http://rvm.beginrescueend.com/rvm/install/

One might be doing ones-self a huge favor also by following Michael Hartl's simple instructions for bootstrapping Ruby. He too is fastidious about maintaining his instructions, which are kept fresh and current:


In any case, upgrading Ruby is a fairly painless process:

1. The first step is to upgrade RVM itself with: $> rvm upgrade

2. Next, reload the RVM shell script: $> rvm reload

3. Then, tell it to install the new Ruby version: $> rvm install 1.9.2-p136
(this will download, compile and install from source, so wait a while)

4. Running $> rvm list will give you a list of all the Ruby installations RVM is managing, with an arrow pointing to the default.

5. Now just tell RVM which Ruby to use as default $> rvm use ruby-1.9.2-p136 and check again with rvm list to verify the new default Ruby installation. You can also use $> ruby --version to double-check.

No comments:

Post a Comment