
Today I needed to set up a new MacBook Pro and as such one of the tasks was to install git on OS X Lion. Being that I am a fan of MacPorts, I decided to start there but I ran into some strange errors. Unfortunately I wound up doing a lot of yak shaving.
The last time I installed MacPorts fresh, it was on a previous MacBook Pro that had OS X Snow Leopard installed. I successfully installed MacPorts and then used the port utility to install git without issue. Later I then updated to OS X Lion and had no issues with git or Xcode.
So from previous experience, I knew that before I could install MacPorts I would need to install Xcode, so I downloaded and installed Xcode 4.3 from the App Store. Then I attempted to install MacPorts, but began seeing errors about not being able to find the make utility. Sure enough, it was not in /usr/bin. After some hunting, I ran across a document titled New Features in Xcode 4.3 which noted the following:
'The command-line tools are not bundled with Xcode 4.3 by default. Instead, they can be installed optionally using the Components tab of the Downloads preferences panel...'
So I installed the command-line tools from the Xcode preferences panel and then proceeded with the MacPorts installation. It completed successfully so I moved on to the actual installation of git. Below is the command I used:
$ sudo port install git-core +bash_completion +doc +svn
Unfortunately this wound up with an error stating:
Error: Failed to install zlibHunting around, I wound up finding a few things such as this MacPorts issue, only to discover that this issue was closed as invalid. So I hunted some more and found this question on Stack Overflow which had one hint but not everything to fix the situation. I also found some advice in a document about Migrating a MacPorts install to a new major OS version or CPU architecture. So below are the steps I took that finally solved the problem:
- Install the Xcode command-line tools from the Xcode preferences panel
- Update the /opt/local/etc/macports/macports.conf file to change from 'developer_dir /Developer' to just 'developer_dir'
- Clean all ports using sudo port clean all (this took a while)
- Now run sudo port install git-core +bash_completion +doc +svn (this took even longer)
