How to install an older version of a port
- Audience: Anyone needing an older version of a port than is currently available in the repository or installed on their machine
- Requires: MacPorts >=1.7
When you upgrade an installed port, MacPorts deactivates the older version but keeps it installed. For example:
$ port installed tcl The following ports are currently installed: tcl @8.4.16_0(active) $ sudo port upgrade tcl [snip] $ port installed tcl The following ports are currently installed: tcl @8.4.16_0 tcl @8.5.0_0 (active) $
If you later discover you would like to go back to the older version, you can activate it, which will automatically deactivate the active version first:
$ sudo port activate tcl @8.4.16_0 ---> Deactivating tcl @8.5.0_0 ---> Activating tcl @8.4.16_0 $
Once you're confident the new version works to your satisfaction, you can uninstall the old one to reclaim disk space:
$ sudo port uninstall tcl @8.4.16_0
If you want to go back to an older version after you've already uninstalled it, or to an older version than you've ever had installed, you can do so by manually downloading the older version of the portfile from the Subversion repository.
Step 1: Finding the right revision
To install an older version of the port, you'll have to manually download the files from the repository. Browse the repository to find the directory of the port you want, then use the Revision Log link in the upper right to find the older version that you want to install. For example, if you wanted to install the older 8.4.16 version of tcl, browse to the lang/tcl directory and look at its revision log. Here you'll note that tcl was updated to 8.5.0 in r32235, so you want the revision before that, which was r30810. Click the @30810 link in the revision log (not the  link) to see the directory as it existed in that revision.
Step 2: Getting the Portfile
Click the Portfile to see it, then download it to disk using the Original Format link at the bottom of the page. The tcl port doesn't have a files directory, but if it did, you should download each file within it as well, and place them in a files directory on your disk in the same place where you downloaded the Portfile.
MacPorts usually runs under a separate "macports" user account with reduced privileges; you must place the Portfile (and files directory, if any) in a place where the "macports" user can read them. In particular, your home directory is not usually readable by other users, so inside your home directory is not a suitable location; using an unsuitable location will result in an error message like Error: Unable to execute port: could not read "/Users/someuser/Desktop/Portfile": permission denied. If you don't mind the OS deleting these files after a few days, or after a restart, you could put them in /tmp, or you could create another directory elsewhere (e.g. at the root of your hard drive) for this purpose.
Step 3: Building the downloaded port
Finally, use the Terminal to cd to the directory where you downloaded the Portfile and type "sudo port install".
Alternative method to getting the port
Subversion can be used as well to fetch an older port, and is simpler for one that has a files/ subdirectory.
Step 1: Install Subversion
sudo port install subversion
This step is optional for Mac OS X 10.5 Leopard and later, which already include a Subversion client, but you may want to install it from MacPorts anyway because its version is likely newer than the one included with your operating system.
Step 2: Finding the right revision
Follow Step 1 earlier to find the right revision for the port you need, e.g. r30810.
Step 3: Checking out the port
Using the revision number, port category and port name, check out the port directory at that revision using the svn command:
svn co -r 30810 http://svn.macports.org/repository/macports/trunk/dports/lang/tcl
This creates a tcl directory in your current location, and populates that with everything the port needs to build. Replace "30810" and "lang/tcl" with the correct revision and category/portname for the port you're interested in.
The following shows a complete example:
port info php5 shows it to be first in the lang category, so it would be located in lang/php5.
svn co -r 53555 http://svn.macports.org/repository/macports/trunk/dports/lang/php5 cd php5 sudo port install +apache2+postgresql83
After this, php5 version 5.2.10 should be installed.
Specifying a subport
Many python libraries, for example, have separate ports for different python versions, but a single port file to describe them all. To specify which version you want, use "subport=...". For example:
cd dports/python/py-pylint sudo port install subport=py27-pylint