RVM has quickly become one of the main ways to install Ruby. Even though the RVM documentation is very solid I’m going to walk through installing RVM and Ruby on a clean install of Ubuntu 10.10 (Desktop). Obviously if you are not using Ubuntu 10.10 you might need to change some of these steps.
I am running Ubuntu 10.10 on VMWare Workstation (the free VMWare Player will work as well).
On my default/clean Ubuntu 10.10 (Desktop) Curl and Git are not installed by default. So with a new Terminal session issue the following command:
$ sudo apt-get install curl git-core
The next command you won’t need to use sudo:
$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
Now you need to update the .bashrc file. Assuming your in your home directory issue this command:
$ sudo pico .bashrc
Paste this to the very end of that file:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
In the same file look for this line:
[ -z "$PS1" ] && return
Replace it with this line:
if [[ -n "$PS1" ]] ; then
Now, right before the first line you added at the end of this file, add this:
The end of your file should look like this:
fi [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
Save the file and exit Pico and exit your terminal session (or reload your session). Open a new terminal session (if you didn’t reload) and issue this command to verify RVM:
$ type rvm | head -n1
The response should be:
rvm is a function
Since I’m installing the MRI (Matz’s Ruby) version of Ruby I also need to install the following packages:
$ sudo apt-get install build-essential bison openssl libreadline5 libreadline-dev zlib1g zlib1g-dev libssl-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev
Note: Keep in mind your not limited to just a particular Ruby, there are many flavors you can install using RVM (JRuby, REE, etc.). See this for more info on your options available. Remember you might need to install other dependencies though so make sure to run this command to verify those dependencies:
$ rvm notes
Finally you can now install Ruby.
For Ruby 1.8.7 use this command:
$ rvm install 1.8.7
For Ruby 1.9.2 use this command:
$ rvm install 1.9.2
Set your new Ruby installation as the default Ruby:
$ rvm --default 1.8.7
$ rvm --default 1.9.2
Verify Ruby is installed and it is the correct version:
$ ruby -v $ gem -v
Install any gems you need but make sure to read this first.