Being a big fan (and user) of the Ruby programming language, one of the first things I install on a new computer/OS is obviously the Ruby interpreter. However, on Ubuntu, some things are more difficult than usual. RubyGems doesn’t work as expected: new gems don’t go to the PATH. Thus, if I were to install Rails or nanoc using RubyGems, their executables wouldn’t work on the command line.
The Debian/Ubuntu way is to install these gems using their own package management. Personally I don’t think that this is such a good idea – the Ubuntu repositories obviously don’t have nearly every gem and if they do, it might not be up to date.
There are obviously many ways around this, and the simplest one is to add the RubyGems “binary” path to the user’s $PATH variable. However, this doesn’t change the fact that other Debian modifications still exist in the Ruby installation (for example, gem update --system is disabled.)
A nice solution is Ruby Version Manager, which is a simple command line application to manage different Ruby installations on the computer. RVM will compile the specified Ruby version for you and handle integrating it with your environment. And since it’s a version manager, switching from 1.8.x to 1.9.x to JRuby to whatever is also easy to do.
So, in order to install rvm, do the following:
bash << (curl http://rvm.beginrescueend.com/releases/rvm-install-head)
On-screen instructions will follow. Afterwards, let’s install Ruby 1.9.1. First we have to install some dependencies, though:
sudo apt-get install curl bison build-essential zlib1g-dev libssl-dev libreadline5-dev libxml2-dev git-core
If you’re not using Ubuntu, there are dependency listings for other distributions in rvm’s website. As an example, the previous link goes to the Arch Linux page.
Next:
rvm install ruby-1.9.1
This will download the Ruby 1.9.1 source code and compile it. You could obviously replace ruby-1.9.1 with ruby-1.8.7 or ruby-head to get 1.8.7 and the cutting edge version. In any case, we’ll want to set our new installation as the user default:
rvm --default ruby-1.9.1
And now, we have a fully functioning Ruby 1.9.1 installation. Any new command line window will use that Ruby install by default. Now go build the next revolutionary web app or something!

Short, fast and sweet… altough I did manage to make it work by putting their line before the return instruction instead of splitting the file in two.
Same thing – works for me without removing the return statement.
Doesn’t work the described way. You can’t use curl before having it installed. So do the apt-get line first then the bash line second. Next: rvm install ruby-1.9.1 doesn’t work. You have to edit the .bashrc as mentioned on the rvm’s website. Put this as the very last line into your .bashrc:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . “$HOME/.rvm/scripts/rvm”
close the cli reopen it and proceed.
Read carefully – “on-screen instructions will follow” refer to the step that requires modification of the .bashrc.