How To Install RVM in Ubuntu Quantal

Categories: Shop Talk

Posted by: admin

06/11/2013

Here’s a post from our resident Linux nerd, Curt!

While trying to learn Ruby on Rails I noticed a lot of tutorials recommending RVM, and since Ruby is rapidly being developed, I agreed with them. RVM, or Ruby Version Manager, allows you to keep, and easily switch between, multiple versions of Ruby to suit your needs.

Since I had Ruby installed on my computer already (since I use SASS) I was curious as to how RVM would manage my system-wide install and the versions I was trying to install with RVM. The answer, unfortunately, turned out to be “not well at all.” So I first purged my system of ruby and ruby1.9.1 (along with my previous installation of RVM) so that I could start over and tell you all about it.

To start, if you type:

$ which ruby

and it returns anything but a blank line, you should run:

$ sudo apt-get purge ruby*

just to make sure we’re on the same page unless you have a good reason to not to.

Additionally, if you’ve played around with .rvm before and when you run which ruby you get output with rvm in it, you’ll probably need to run:

$ rvm implode

or:

$ sudo su
# rvm implode

as I did in my case, since the install contained files in directories that my used didn’t own explicitly.

Let’s Do This

I’ll be paraphrasing the step-by-step installation as outlined here in this section. This guide is designed for 12.04, but I’m running 12.10 and will alter any steps for the newer version as I go.

First, you need to make sure you have some packages installed. Open up Terminal and run:

$ sudo apt-get update
$ sudo apt-get install git curl

While Terminal is still open, go up to Edit > Profile Preferences, click the Title and Command tab, and check Run command as login shell. You’ll want to keep that enabled. Next, type:

$ curl -L get.rvm.io | bash -s stable

This downloads RVM and pipes it through bash for installation.

At this point, the RVM installation threw a warning to make sure I was sourcing ~/.profile inside ~/.bash_profile, or to add it to ~/.bash_login if ~/.bash_profile doesn’t exist. I added:

source ~/.profile

… to my ~/.bash_profile file.

Next up we source the newly created RVM shell script:

$ source ~/.rvm/scripts/rvm

And install more dependencies, including the most up-to-date version of nodejs:

$ sudo apt-add-repository ppa:chris-lea/node.js
$ sudo apt-get update
$ sudo apt-get -y install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion nodejs

And there you go, you’ve got RVM all ready to go! Let’s pop a version of Ruby in there! The tutorial I’m running wants me to use Ruby 1.9.3, so I will, but install whatever version you’d like!

rvm get head && rvm reload
rvm install 1.9.3

Now when I try to find out which version of Ruby I’m running, I get this:

$ which ruby
/home/meowsus/.rvm/rubies/ruby-1.9.3-p392/bin/ruby

I’ve got Ruby right where I want it.

Now to get the right version of Gem and Rails, which — again — is specific to the tutorial I’m using, which by the way is this one, so I ran:

$ gem update --system 1.8.24
$ gem install rails -v 3.2.13

And that’s just about it. You’ve got Ruby, you’ve got Gem, and you’ve got Rails!

EDIT: Since I had to implode my RVM install and start over, I was getting strange errors when trying to run bundles. It seemed like RVM would work properly for the current terminal session only after I ran:

$ source ~/.rvm/scripts/rvm

… each time I needed to do anything. Very annoying. To fix this, and a big ups to mpapis in Freenode’s #rvm channel, I ran:

$ rvm get head --auto-dotfiles

… then restarted my terminal.

Share: