Install Ruby on Debian using RVM

I have a small bit of shell scripting fu and have acquired the taste for more programming. Ruby has the reputation for being a friendly language to newbies and I have decided to give it a go.

There are a few different methods for installing Ruby on Debian Wheezy ... I opted to use a third-party tool called the Ruby enVironment Manager (RVM). Grabbing the latest version of Ruby + the ability to host multiple, self-contained Ruby installations is made easier with RVM.

Installing RVM for the use of a single user creates ~/.rvm to hold all the Ruby-related files. Get started by downloading curl -L | bash -s stable.

Load RVM source ~/.rvm/scripts/rvm.

Check for additional requirements rvm requirements.

I needed to install these extras ...

$ sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion

Now I can use RVM to install the latest stable version of Ruby rvm install 1.9.3.

The current system-wide install of Ruby is ... To test my new RVM configuration and confirm that I am using my later, freshly-installed version I run:

$ type rvm | head -n 1
rvm is a function
$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
$ which ruby

It works. Good!

But not for long. I ran into two problems: trying to load RVM as a shell function failed to work in new shells, and I discovered that login shells were no longer reading ~/.bashrc settings.

RVM made two modifications that in Debian Wheezy need to be altered:

To Fix:

1/ Copy the RVM function in ~/.bash_login ...

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

... and place it at the end of ~/.bashrc

2/ Remove ~/.bash_login

3/ Edit the PATH setting to include extra directories

Now it works. Good good!


More • rubyprogrammingdebianlinux