Recently I had trouble using MacPorts on Lion, for whatever reason. But I managed to find the fix, and here they are.
Unable to do selfupdate:
~$ sudo port selfupdate
---> Updating MacPorts base sources using rsync
MacPorts base version 2.0.4 installed,
MacPorts base version 2.1.2 downloaded.
---> Updating the ports tree
---> MacPorts base is outdated, installing new version 2.1.2
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: shell command failed (see log for details)
Cause: ??? (shame on me for not checking the logs)
Solution: Re-install Xcode (ref: MacPorts ticket #30507).
Before re-installing Xcode, I had to uninstall my existing one. All I did was:- Search for the Xcode executable from Spotlight
- Open the folder where the Xcode executable is (usually under /Applications).
- Drag the icon to the Trash bin. OR drag the Launcher icon to the Trash bin (this will prompt for are-you-sure-you-want-to-uninstall? confirmation). Click Yes/OK if asked.
If you're able to successfully re-install XCode (mine was 4.4.1 as of this writing), you should be able to run ~$ sudo port selfupdate successfully.
p.s. Actually, I also installed MacPorts 2.1.2 manually (go to MacPorts website, download the .dmg, install, etc.). So now I'm not entirely sure which fixed it.Unable to install Octave
~$ sudo port install octave
Warning: The Command Line Tools for Xcode don't appear to be installed; most ports will likely fail to build.
Warning: See http://guide.macports.org/chunked/installing.xcode.html for more information.
Error: Unable to open port: can't read "build.cmd": Failed to locate 'make' in path: '/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' or at its MacPorts configuration time location, did you move it?
Error: Unable to execute port: upgrade perl5 failed
Cause: (the error message was pretty explanatory on this one) "The Command Line Tools for Xcode don't appear to be installed" and (hence) "Failed to locate 'make' in path".
Solution: Install the XCode Command Line Tool.
- Launch XCode.
- In XCode, go to: Preferences > Downloads
- Click "Install" for the "Command Line Tools" item (the screenshot shows that it's already installed).
p.s. Prior to installing the Command Line Tools, I ran across this post: "GCC non-existent in Lion". So I also did what was recommended there: made a symbolic link to llvm-gcc-4.2 to /usr/bin/gcc. But the location of the newest Xcode directory in my system is a little different:
~$ sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/bin/llvm-gcc-4.2 /usr/bin/gcc