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.

<!–break–>

This entry was posted in Linux, Ruby. Bookmark the permalink.

One Response to Installing Ruby on Debian and Ubuntu

  1. dg says:

    good advice – wish i found it sooner. i’ve been constantly struggling with broken ruby/gem installations, having mixed the frozen debian repository installation material with the up to date gem material.

    on debian and similar distro’s, you’ve basically got two competing and occasionally incompatible code repositories mixing together unless you do ruby & gems from source release — it’s only a matter of time before it breaks

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>