Installing RVM on Linux

of 06


Getting your Linux environment set up for RVM is the hardest part of installing RVM itself. If you're unfamiliar with the process of compiling Ruby from source, you can get a little lost. Thankfully, distributions like Ubuntu make things pretty easy.

These instructions are written on Ubuntu. For the most part, they will apply to any Debian or Ubuntu based distribution. For other distributions, the package names may differ, but the same libraries and such need to be installed.

of 06

Install GCC and Other Tools

First and foremost you need the C compiler and the Make utility. These are usually bundled together with some other tools and behind the scenes magic in a package called build-essential. So this is the first package that should be installed.

$ sudo apt-get install build-essential

In addition, RVM will also need curl to download files. This is also a simple apt-get.

$ sudo apt-get install curl
of 06

Install Development Libraries

Next, you're going to need a few libraries and their development package counterparts. Two of these libraries are readline, which lets you edit lines of text in bash or IRB, and zlib, which Rubygems will need to function. Also included is OpenSSL and LibXML.

$ sudo apt-get install zlib1g-dev libreadline-dev libssl-dev libxml2-dev
of 06

Install RVM

Now that you're all set up, install RVM itself. This is done via a shell script which you can download and run directly with a single command.

$ bash -s stable 

Append the following line to your ~/.bashrc file.

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM

And then reload your bash environment (or close the terminal window and open a new one).

$ source ~/.bashrc

of 06

More About Requirements

In later versions of RVM, an rvm requirements command was added to give you more information about the build and run requirements for various rubies. You can see and peruse this list of requirements by running rvm requirements.

$ rvm requirements

It even gives you handy apt-get commands you can simply copy and paste.

of 06

Install a Ruby

You'll probably want to install the MRI Ruby interpreter (the official Ruby interpreter, the one you're probably already familiar with). To do that (after you installed the build dependencies, see the previous steps), it's a simple rvm install 1.9.3. This will give you the MRI interpreter version 1.9.3 (the stable release at the time this article was written) at the latest patch level.

$ rvm install 1.9.3

And that's it. Remember to rvm use 1.9.3 before you start using Ruby and that's it, Ruby is installed.