Installing Ruby on Debian and Ubuntu

While you can use the version of Ruby that comes with Debian and Ubuntu's repositories, you'll find it to be a bit out of date. It's probably fine for most usage, but if you're like me and like to keep Ruby and its gems up to date, you'll want to install it from source.

Fortunately it's easy. Simply run:

sudo apt-get remove ruby libruby libruby1.8 ruby1.8 irb rdoc ri
sudo apt-get install libssl-dev libreadline-dev
mkdir ~/sources
cd ~/sources
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p111.tar.gz
tar xfz ruby-1.8.6-p111.tar.gz
cd ruby-1.8.6-p111
./configure --prefix=/usr
make
sudo make install

This will install Ruby. Now, to install Ruby Gems:

mkdir ~/sources
cd ~/sources
wget http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz
tar xfz rubygems-1.0.1.tgz
cd rubygems-1.0.1
sudo ruby setup.rb

Now you can use gem install to install any gem you want. If you want to install RMagick, note the article RMagick on Ubuntu Gusty (the instructions also work for Debian).

This method of installing Ruby and Ruby Gems is completely portable, you can upgrade to the latest release of both easily by simply substituting the version numbers of the packages in the instructions above.

Comments

Wonderful!

Thank you very much for this tutorial! Works like a charm.