Monday, April 11, 2011

rvm with Ubuntu 10.04 and 10.10

If you plan on doing a lot of development in ruby, then rvm (ruby version manager) is the way to use lots of different ruby versions and gems. If you just want to run ruby, you should use your system's package manager.

This is a condensed version of Chistopher Irish's excellent write-up

(leading $ is the bash prompt)

$ sudo apt-get install curl git-core ruby
$ bash < <(curl -s

If you haven't already replaced your .bashrc, you probably have a line in there like this:
[ -z "$PS1" ] && return

Replace that line with:

if [[ -n "$PS1" ]]; then

Then, add this to the last line of the .bashrc file (however, you can leave off that very final, dangling 'fi' if you did NOT have a return statement that you replaced earlier).

if [[ -s $HOME/.rvm/scripts/rvm ]] ; then source $HOME/.rvm/scripts/rvm ; fi


There are going to be prerequisites to installing most ruby's. Use the command rvm notes to discover those dependencies for your system.

Okay, we'll grab some prerequisites for compiling 1.9.2:

$ sudo aptitude install build-essential bison openssl libreadline5 libreadline-dev curl git-core zlib1g zlib1g-dev libssl-dev vim libsqlite3-0 libsqlite3-dev sqlite3 libreadline-dev libxml2-dev git-core subversion autoconf

Now, we can list the ruby versions we can install, install 1.9.2, and set it as default.

rvm list known  # see which ruby versions we could install
rvm install 1.9.2-head
rvm --default 1.9.2-head  # make ruby 1.9.2 our default

1 comment:

eldon said...

Great post, I have used it before, but now I don't have to keep searching for his post when installing on different computers. Sudoit comes to the rescue.