Fixing broken perl5 / perl5.8 macports installation

So after spending an entire weekend rebuilding my Macbook last month, with a nice shiny new Macports installation that successfully upgraded the installed ports on the first two times I ran sudo port upgraded outdated, I was somewhat dismayed when the third attempt failed dismally:

---> Installing perl5 @5.12.3_0+perl5_12
---> Deactivating perl5 @5.8.9_0
---> Cleaning perl5
---> Activating perl5 @5.12.3_0+perl5_12
Error: Target org.macports.activate returned: Image error: /opt/local/bin/a2p is being used by the active perl5.8 port. Please deactivate this port first, or use ’port -f activate perl5’ to force the activation.
Portfile changed since last build; discarding previous state.
---> Computing dependencies for apache2
---> Dependencies to be installed: perl5
---> Activating perl5 @5.12.3_0+perl5_12
Error: Target org.macports.activate returned: Image error: /opt/local/bin/a2p is being used by the active perl5.8 port. Please deactivate this port first, or use ’port -f activate perl5’ to force the activation.
Error: Failed to install perl5
Log for perl5 is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_perl5/main.log
Error: The following dependencies were not installed: perl5
Error: Unable to upgrade port: 1
To report a bug, see <http://guide.macports.org/#project.tickets>

After wasting valuable minutes of my life reading this thread, I managed to figure out a nice, clean fix.

Firstly, use this command to see which versions of perl5 you have on your system:

sudo port installed | grep perl

In my case the output looked like this:

  perl5 @5.8.9_0
  perl5 @5.12.3_0+perl5_12
  perl5.12 @5.12.3_1 (active)
  perl5.8 @5.8.9_3 (active)

So I used these two commands to remove perl5.8 from my system:

sudo port uninstall perl5 @5.8.9_0

sudo port uninstall perl5.8

I then reissued the sudo port upgrade outdated command and, upon doing so, tons of things recompiled (mostly stuff that was dependent on p5). The process took a while but completed successfully and, most importantly, GIMP worked fine afterwards. :-)

Yet Another Programming Blog

Where James Gordon rambles about PHP and web development in general.

Find me on Twitter Find me on Stack Exchange Find me on Github Subscribe