I recently had to set up Ruby 1.8.6 on a server running Debian Etch stable. Debian is famous for its slow release cycle - Debian stable often lags far behind other Linux releases in terms of software package versions, though it provides an amazingly comprehensive set of well-tested packages and great stability, making it a great choice as a server platform.
However the current release, Etch, comes with Ruby 1.8.5, which is a bit old and has some problems running Mongrel. It’s very easy to download and compile Ruby, installing it in /usr/local, but this bypasses Debian’s packaging system. But it’s easy to do better; using Ruby’s package manager to install Ruby and maintaining all the benefits of having your installed software under package management.
Note that you’ll need to be root to run these commands.
Make sure you haven’t installed ruby in your package manager yet.
Or, if you have, uninstall it before proceeding to avoid package conflicts. Read the comments on the post below for more details.
1) Update your /etc/apt/sources.list, to use Debian’s “unstable” source packages:
deb-src ftp://debian.mirrors.tds.net/debian/ unstable main non-free contrib
2) Update your list of available packages:
apt-get update
3) Install Ruby’s build dependencies:
apt-get build-dep ruby1.8
4) Install Debian’s package management development programs:
apt-get install dpkg-dev
5) Download the Ruby source package and build it:
apt-get source -b ruby1.8
This took about 5 minutes on my system with SATA disks and a 2 gig P4. It creates the following packages:
- irb1.81.8.6.111-4all.deb
- libdbm-ruby1.81.8.6.111-4i386.deb
- libgdbm-ruby1.81.8.6.111-4i386.deb
- libopenssl-ruby1.81.8.6.111-4i386.deb
- libreadline-ruby1.81.8.6.111-4i386.deb
- libruby1.81.8.6.111-4i386.deb
- libruby1.8-dbg1.8.6.111-4i386.deb
- libtcltk-ruby1.81.8.6.111-4i386.deb
- rdoc1.81.8.6.111-4all.deb
- ri1.81.8.6.111-4all.deb
- ruby1.81.8.6.111-4i386.deb
- ruby1.8-dev1.8.6.111-4i386.deb
- ruby1.8-elisp1.8.6.111-4all.deb
- ruby1.8-examples1.8.6.111-4all.deb
6) Install the packages:
dpkg -i *.deb
You can also just install the ones you think you’ll need; at very least you’ll want ruby1.81.8.6.111-4i386.deb, and the ri, rdoc and irb packages.
7) Bask in the Ruby 1.8.6 goodness:
norman@randomba:$ ruby -v
ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]
Thanks for this entry! I’ve been having some issues compiling Ruby 1.8.6 on Dapper and these steps took care of the problems. Thanks again, and great work!
Thanks for the article, but your system and mine must be very different
The dpkg -i *.deb step failed decisively.
Someone on the #debian irc channel suggested aptitude -f install which resulted in this:
http://pastebin.ca/965596
Ruby is gone now - glad I didn’t try this on a production system
Sorry to hear that… it worked for me in January but it’s possible that the packages in unstable have been updated since then.
Phew. After much pain and suffering, I eventually purged the libruby1.8 package and that seemed to allow everything to proceed:
sudo dpkg –purge libruby1.8
Not sure why the install failed because of that, but everything seems to be working now. Thanks again for the article - it kept me from resorting to my old standby of:
./configure
make
make install
For what it’s worth, here is the error log:
http://pastebin.ca/965639
That’s not the original error log though, but the one after mucking around a bit, and then restarting the steps from square one. Maybe there was just something strange about how libruby1.8 was originally installed on my system.
That is odd, but it doesn’t seem beyond belief that the packages could conflict. I think I had not installed ruby at all yet when I did this, so I didn’t have the problems you did. I’ll make a note of it in the blog post.
this might help some of you hacing problems as well:
dpkg –purge –ignore-depends=libmysql-ruby1.8,libopenssl-ruby1.8 libruby1.8
If you get an error trying to get rid of the old ruby.
Getting rid of the old ruby was (for me) simply a matter of
apt-get remove libruby1.8
No need to ignore/force/purge anything.
This seems to install ruby 1.87, which is not recommended yet for Rails (well, from what I can tell: the Rails download page says “Ruby 1.8.7 still has some bugs to straighten out.”, which I assume is equivalent to “don’t use it yet”). Otherwise it worked ok for me, excepting a failed dependency on a new version of emacs.
Thanks for these instructions anyways — very interesting!
Yeah, looks like they have updated the version to 1.8.7 since I wrote this. Rails versions less than 2.1 are *incompatible* with Ruby 1.8.7, so you really should stick with 1.8.6 unless you are using Rails 2.1 - and even if you are, 1.8.6 is probably a better choice.
At this point I would highly recommend installing the Phusion guys’ Ruby Enterprise Edition despite the terrible name. It’s basically 1.8.6 with the security patches applied in a sane way (sorry, article in Portuguese, Babelfish to the rescue!). When used with Passenger (mod_rails) it can consume up to 30% less RAM. I’m using it on a production site and am very happy with it.
They don’t have a Debian package, but I’m sure some enterprising soul can make one… perhaps me if and when I get the time!