Wednesday, March 28, 2012

Installing RVM on Ubuntu 11.10

RVM is an amazing tool. It's a tool that enables mixed you to switch between different version of Ruby with a simple command line entry.

Setting it up posed a few challenges for Ubuntu Server 11.10. I've installed it a few times in the past, but I'd always installed it in "single user mode". Meaning, I only installed it for my login which gave me the ability to install things in my own sandbox without requiring elevated privileges. However, for my web server I wanted to set up RVM for all users. This way my Git user can specify Ruby versions on demand just the same.

To do this, I followed the steps on their website, but I couldn't get my "rvm install x.x.x" commands to work. When I typed the following command:

rvm install 1.9.2

I got a slew of errors. This was never a problem for me in 'Single User' install mode, so I wasn't sure what the problem could be. I didn't do my reading and ended up trying all kinds of things. I checked the requirements, installed all kinds of additional packages, even updated / upgraded my entire environment using:

sudo apt-get update

as well as

sudo apt-get upgrade

I waited and waited while it updated my system. When I tried entering the rvm install command again, it still generated the same set of errors. As it turns out, I simply had to append rvmsudo at the front of this command, like so:

rvmsudo rvm install 1.9.2

This preserves the RVM environment and passes it onto sudo.  Once I did that, things started working. :) Moral of the story: RTFM!

Oh and you should note that this doesn't set v1.9.2 as your current Ruby version yet; it merely installs it. To begin using it, type the following command:

rvm use 1.9.2

Hope this helps somebody.

No comments: