Install Old Versions of Ports Using MacPorts

MacPorts is my preferred way of installing, managing, and upgrading much of the software I have on my Mac.

I’m setting up a new work machine today and I need to install ruby 1.8.5 on my machine for Rails to be happy.

Unfortunately, you can’t do something simple like specifying the version of the port you want to install unless it’s in a local repository.

Fortunately, my friend Stephen Chu had this problem about a year ago and has a nice procedure on how to do it. I’m going to update it for MacPorts and ruby 1.8.5 here.

1) Find out the svn revision number of the Portfile that has 1.8.5 by looking at:

http://trac.macosforge.org/projects/macports/log/trunk/dports/lang/ruby/Portfile

In my case it is 21127.

2) Set up a local port repository. In the file /opt/local/etc/macports/sources.conf, add this line before the rsync line:
file:///Users/Shared/dports and create that directory.

3) Install the port into your local repository.

cd /Users/Shared/dports && svn co --revision 21127 http://svn.macports.org/repository/macports/trunk/dports/lang/ruby/ lang/ruby/

4) Run portindex so that ports now finds your new (old) version of ruby.

portindex /Users/Shared/dports

5) Now you should be able to see ruby @1.8.5-p12 in addition to @1.8.6 by running:

port list

6) Install Ruby

sudo port install ruby @1.8.5-p12

You should be up and running now, so to check, run:

ruby -v

You will see something like this:

ruby 1.8.5 (2006-12-25 patchlevel 12) [i686-darwin8.10.1]

Now, if you want versions of ruby that MacPorts doesn’t have (later patchlevels for instance), you can modify the portfiles by hand, but I’ll leave that for another post.

Posted: October 20th, 2007
Categories: Ruby, Work
Tags:
Comments: 9 Comments.
Comments
Comment from Jim - July 3, 2008 at 10:01 pm

step 3 had to be as follows (with -r after the URL) for me.

cd /Users/Shared/dports && svn co http://svn.macports.org/repository/macports/trunk/dports/lang/ruby/ -r 34233 lang/ruby

Thanks for this.
Jim

Comment from Matt - December 30, 2008 at 2:13 pm

Thanks so much! Very helpful.

Comment from joe - December 30, 2008 at 3:05 pm

You’re welcome.

[...] and Joe Homs go into very excellent and welcome detail in their posts on how to pull this off. A summary of what [...]

Comment from Ryan Sobol - February 19, 2009 at 1:17 pm

Very clear instructions — worked for me with ruby @1.8.6-p114 with MacPorts v1.700. Here’s the svn command I used:

svn co –revision 36429 http://svn.macports.org/repository/macports/trunk/dports/lang/ruby/ lang/ruby/

Thanks!

Comment from Ryan Sobol - February 19, 2009 at 3:15 pm

BTW – ruby 1.8.6 is *not* compatible with a header change in OpenSSL 0.9.8j. See http://www.ruby-forum.com/topic/179010 for the details…

So, I used the same technique described in this article to download the Portfile for OpenSSL 0.9.8i.

svn co –revision 45087 http://svn.macports.org/repository/macports/trunk/dports/devel/openssl/ devel/openssl/

Don’t forget to portindex again!

I hope this helps someone!

[...] The screen port @4.0.3_1 (version 4.0.3 revision 1) is free of these problems and, with a little bit of work, you can install this version via MacPorts. The instructions below are based on Joe Horns’ post, install old versions of ports using MacPorts. [...]

Comment from Johan Rylander - June 11, 2009 at 3:15 am

tnx! very clear and useful.

Comment from Kurtiss Hare - July 30, 2009 at 10:28 pm

Not sure if this is necessary for everyone, but in my case, I had to edit /opt/local/etc/macports/sources.conf to include the local repository I just created and indexed, before macports would pick it up:

file:///path/to/dports