Wednesday, December 13, 2006

Specifying ruby 1.8.4 to install using DarwinPorts

Recently I had to install ruby 1.8.4 onto my Mac. I have always been using DarwinPorts (v1.320 ) and it has served me well. But this time it is giving a little trouble. On the port tree (port list ruby) DarwinPorts gives me ruby 1.8.5, which as we all know breaks script/breakpointer for now. It does not give me the option to specify a previous ruby version to do port install, as if 1.8.5 is the only ruby that it recognizes.

I suppose you could compile ruby from source by hand, but we developers are just hard heads and refuse to give in...

Fortunately, there is a solution. (Thanks to Marc Selig)

1) Find out the svn revision number of the Portfile that has 1.8.4 by looking at:
http://trac.macosforge.org/projects/macports/log/trunk/dports/lang/ruby/Portfile
In my case it is 16709.

2) Set up a local port repository. In the file /opt/local/etc/ports/sources.conf, add the line:
file:///Users/Shared/dports

3) Install the port into your local repository.
cd /Users/Shared/dports
svn co --revision 16709 http://svn.macports.org/repository/macports/trunk/dports/lang/ruby/ lang/ruby/
portindex /Users/Shared/dports

4) Now you should be able to see ruby @1.8.4 in addition to @1.8.5 by running "port list". Run "port install ruby @1.8.4" and you are up and running.