Saturday, February 18, 2012

Installing Ruby 1.9.3 via RVM in Ubuntu 11.10

This morning, I needed to install Ruby 1.9.3 on my Ubuntu 11.10 system, but it took a little bit of trial and error. I did get it working, using (approximately) the following steps.


First, install RVM. This is nice and easy.

sudo apt-get install ruby-rvm

It seems that this is not the latest version of RVM, so it has some problems trying to install 1.9.3. So at the command line, do the following:

sudo rvm get head
sudo rvm reload

Ruby 1.9.3

Unfortunately, just typing rvm install 1.9.3 will not work, so type the following instead:

sudo rvm install 1.9.3-p125

This will take quite a while, since it downloads the Ruby source, configures it and compiles it. After it is done, set the default Ruby version in new shells to the version you just installed:

sudo rvm --default use 1.9.3-p125

Local Shell Setup

Even after RVM and Ruby 1.9.3 are installed, you will need to set up your local .bash_profile, since the RVM .deb file will not do that for you. In Ubuntu, RVM is installed in /usr/share/ruby-rvm, so add the following line to the end of your .bash_profile:

[[ -s "/usr/share/ruby-rvm/scripts/rvm" ]] && . "/usr/share/ruby-rvm/scripts/rvm"

Then, either open a new shell or source your .bash_profile, thus:

. ~/.bash_profile

Test It Out

Now, try running Ruby:

ruby -v

If everything is working properly, you should see something like:

ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]

No comments: