Installing Ruby 1.9.2 on Ubuntu 12.04 LTS (Precise Pangolin)

how-to
Jul 9, 20122 mins

Installing Ruby version 1.9.2 (which as of this writing, is not the most recent version, however, our production stack relies on this version for now) on Ubuntu Precise Pangolin (12.04 LTS) can be a bit tricky due to a nasty OpenSSL incompatibility. Nevertheless, with a sneaky code edit, you can be on your way using 1.9.2 in a matter of minutes.

First and foremost, for Ubuntu instances, I use a handy set of installation scripts, dubbed Ubuntu Equip, which you can find on Github (note, I wrote these scripts). Ubuntu Equip has a Ruby 1.9.2 script — simply type from your Ubuntu instance’s command line:

$> wget --no-check-certificate <a href="https://github.com/aglover/ubuntu-equip/raw/master/equip_ruby.sh">https://github.com/aglover/ubuntu-equip/raw/master/equip_ruby.sh</a> && bash equip_ruby.sh

This’ll update various system development libraries and ultimately it’ll download, unzip, and attempt to install Ruby 1.9.2; however, if you aren’t careful, you’ll miss a error a few minutes into the install. The error is easy to miss because after attempting to install Ruby, the script will go on to successfully install RubyGems and Bundler. Because Ubuntu 12.04 already has an older version of Ruby, you won’t necessarily notice any issues unless you type ruby -v, which’ll unveil the problem.

To fix the error (which is a compilation issue), you’ll need to first change directories into ruby-1.9.2-p180 and then edit the ossl_ssl.c file, found in ext/openssl. In this file, comment out (or delete) the lines:

OSSL_SSL_METHOD_ENTRY(SSLv2),
OSSL_SSL_METHOD_ENTRY(SSLv2_server),
OSSL_SSL_METHOD_ENTRY(SSLv2_client),

Incidentally, this code occurs on lines 110-112. Now you’ll need to recompile things; thus, type make followed by make install.

Typing ruby -v should now yield an ever so pleasing ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux].

andrew_glover

When Andrew Glover isn't listening to “Funkytown” or “Le Freak” he enjoys speaking on the No Fluff Just Stuff Tour. He also writes articles for multiple online publications including IBM's developerWorks and O'Reilly’s ONJava and ONLamp portals. Andrew is also the co-author of Java Testing Patterns, which was published by Wiley in September 2004; Addison-Wesley’s Continuous Integration; and Manning’s Groovy in Action.

More from this author