Installing RVM on Debian Lenny

Posted on April 6, 2010


My work has seen me doing a lot of work in ruby recently and more specifically in rails. I recently have been making a lot of use of Ruby Version Manager (RVM). This is a little gem (pun intended) and allows you to easily install multiple versions of ruby, and manage multiple sets of gems for each of these ruby installations. All in all a very nifty little gem and has saved me a huge amount of time. I primarily setup my development environments on throw away virtual machines so that I don’t end up hosing my actual computer.

Currently my OS of choice for my VMs is Debian Lenny. This is a rundown of the commands that need to get up and running with rvm.

Rather then taking this “gem install” approach you can just run;

bash < <(curl

Thanks to Wayne for the really quick comment 🙂

First start off by install ruby and rubygems from the Debian repositories;

apt-get install ruby rubygems

Once this is done I like to make sure that I have the latest version of rubygems, this is done through the handy rubygems-update gem since the Debian rubygems package disables gem update --system;

gem install rubygems-update

Once this is complete you now need to install rvm;

gem install rvm

The next step after installing the rvm gem is to finalise the installation by running the rvm-install command. Depending on your setup you may be able to run this directly if the rubygems bin directory is on your path. If not then you will need to run;


Now we need to follow the final setup phase for rvm which is given to us by rvm-install. In /home/<username>/.bashrc you need to comment out the line [ -z "$PS1" ] && return and add the following code to the end of the file;

if [[ -s /home/<username>/.rvm/scripts/rvm ]]; then
  source /home/<username>/.rvm/scripts/rvm

Once this is done you will need to logout of your shell and back in again for the settings to take effect. If you run rvm list you should now see that you have no rvm managed versions of ruby installed and then there is the system version which is what aptitude installed for us. Also a warning about the command file not being found. This is solved by;

apt-get install file

Now before installing an rvm managed version of ruby there are a final few dependencies that need to be installed;

apt-get install build-essential curl zlib1g-dev libreadline5-dev libxml2-dev libsqlite3-dev

Then all you need to do is run;

rvm install 1.8.7

You now have a ruby environment setup as I set mine up ready for use. One thing to note is that to install gems you should use rvmsudo rather then sudo.

Tagged: , ,
Posted in: ruby