Resurrect MacPorts on OS X Mountain Lion (10.8)

Installing Mountain Lion on release day came with some issues,
not that we assumed that everything would just work out of the box 😉

If you are using MacPorts, as most technicians who choose OS X to be
their operating system, you might notice that it stops working:

Example:

creo$ sudo port selfupdate
Installing new MacPorts release in /opt/local as root:admin; permissions 0755; Tcl-Package in /Library/Tcl
Error: /opt/local/bin/port: port selfupdate failed: Error installing new MacPorts base: command execution failed

Well, no need to panic, help is here!

Read more after the break…

Our beloved MacPorts rely on Xcode, to be more specific on Xcode’s command line tools,
the very command line tools that are not there any more since the Mountain Lion update
deprecates your former Xcode installation.

Perform the following steps to get your MacPorts up and running again:

  • Open the App Store
  • Install Xcode
  • Launch Xcode and go through the setup process,
    you may delete your former installation to save disk space at this stage.
  • Go to the Xcode Preferences
  • Open the Downloads Tab
  • Listed under “Components” you will find the Command Line Tools. Install them.
  • You’re done!

 

Try to start the MacPorts selfupdate mechanism again.
You may notice the following error message:

Warning: Your developer_dir setting in macports.conf points to a non-existing directory.
Since this is known to cause problems, please correct the setting or comment it and let macports auto-discover the correct path.

 

On my system, the setup routine of Xcode obviously tried to avoid conflicting with the
former installation by installing to the following Directory:    /Developer-3.2.2 

There are two methods of dealing with this:

  1. Create a Soft- or Hardlink from /Developer-3.2.2 -> /Developer.
    This will fix the issue, but it’s more workaround than a real fix.
  2. Open the MacPorts configuration file at /opt/local/etc/macports/macports.conf
    and change the path described as “developer_dir” to reflect your Systems Developer folder,
    in my case “/Developer-3.2.2” as mentioned above.

 

Thinking about usability, I’d suggest the MacPorts maintainer(s) to give the user more
detailed Informations about the reason that might cause such problems.

Instead of complaining about the inability to execute a certain command,
a notice that the Xcode CommandLine Tools may be missing would have been
a quite handy hint 🙂

 

 

creo
http://creo.blackmesa.at

  1. Since Xcode whateverversion the developer directory moved out of the root.

    This worked fine:
    sudo ln -s /Applications/Xcode/Contents/Developer /Developer

    Regards,
    Mikael Grön

      • Lorenzaccio
      • November 28th, 2012 3:35pm

      It is even better if you actually type this :

      sudo ln -s /Applications/Xcode.app/Contents/Developer /Developer

      😉

  2. Thanks guys, you’re absolutely right.

    • Anderson
    • August 31st, 2013 10:11pm

    Hi!

    Thank you for your tip.

    I was trying to install the latest update of Ruby (1.9.2) on OS X Mountain Lion (10.8.4), but I was not getting.

    I followed your tip and installed the latest Xcode (4.6.3) and Command Line Tools. And so the MacPorts worked perfectly and I could run the RVM to install Ruby.

    Thank you!

  1. No trackbacks yet.