Friday, March 12, 2010

Quick Way Out of Ubuntu's Rubygems Jail

This post offers a quick method for overwriting the system-supplied RubyGems binary on Ubuntu (and any other Debian derivative) with a pristine version from the RubyGems authors.

Method
The following commands will do the trick.
sudo apt-get install rubygems-update
sudo /var/lib/gems/1.8/bin/update_rubygems

After installing the pristine version of RubyGems, you will have to re-install all your gems. This is because Ubuntu/Debian also modifies the path where RubyGems stores its gem data.

Motivation
Debian cripples RubyGems in various ways, to make it fit in with the overall Debian philosophy.

The most unfortunate change is that RubyGems will not update itself automatically, and we have to wait for Debian maintainers to package the updates. Another annoying change is that Debian's RubyGems will not install launcher scripts in /usr/bin, so we cannot use rails or rake by straight-forward gem installation.

While the path problem is easy to fix (sudo echo "PATH=/var/lib/gems/1.8/bin:$PATH" > /etc/profile.d/rubygems1.8.sh), there's no straight-forward solution for getting updated RubyGems. At the time of this writing, bundler (needed by the Rails 3 beta) requires RubyGems 1.3.6, and the version in Debian is 1.3.5.

I hope you have found this post to be useful, and I'm looking forward to your comments and suggestions.