Ruby 1.8.7/1.9.3 in Ubuntu 11.10 (using RVM Single-User installation)

As a Ruby developer, I'm often using different versions of the language to create scripts and Ruby on Rails applications. Packages for Ruby are available for Ubuntu through the official repositories but you might want to use Ruby Version Manager to keep things a bit simpler.

I'll be using the official installation instructions for Ruby Version Manager in the Virtual Machine created in my first post, you might want to use your own computer with Ubuntu already installed and the only difference is that you might already have the required packages installed.

  1. You will need curl and git to get the source code using the official script, to install the packages use the following:
    sudo apt-get install curl git
  2. If you want to use SSL you need the OpenSSL libraries available, for Ruby on Rails this is a requirement, to install the package use the following:
    sudo apt-get install libssl-dev
  3. If you like to use the Interactive Ruby Shell (IRB), you probably want to install the GNU readline libraries using the folowing:
    sudo apt-get install libreadline-dev


Everything will be done as user, no need for administrative rights (or sudo), use the following command to install Ruby Version Manager:
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

Once the installer finishes and you are back to your command line you need to log out and log in again to have Ruby Version Manager available (this is the preferred way for initial installations).


After your log in, you will have Ruby Version Manager installed and it is time to install Ruby. To install both versions (1.8.7 and 1.9.3) use the following commands:
rvm install 1.8.7
rvm install 1.9.3

After the installation of Ruby you need to select the default version to be used (even if you only installed one), use the following command to set the version 1.9.3 as default (of course, you can change the version number if you like):
rvm use 1.9.3 --default

You can change the default Ruby version anytime you want using the previous command, or you can change it temporary in your current session or terminal using it without the default flag (everytime you log in you will have the default version available):
rvm use 1.8.7

Ruby Gems will be installed as well, no need to download and install. Please note each Ruby version will have its own Gems, you can start to install Gems right away using the gem command.

I hope this will help someone out there, please feel free to send any comments.

No comments: