October 5, 2007
Every once in a while you’ll here or read about an absolutely awesome command line utility or X11 program that you must have. After consulting the great Oracle, Google you find that the program you want is in Macports which for those who are not comfortable at the command line may cause some issues. Fear not though. Here is a very newbie guide to installing it.
Caution! This How To includes typing commands at the command line. When possible I’ve included the exact command that you should type. Simply cut and paste it, then hit enter and it should work. If not feel free to leave a comment and I’ll help out, or find your local Apple Guru.
First a bit of history. Macports, like a lot of OSX got it’s start in the FreeBSD Project which is a Unix derivative. Originally called DarwinPorts after Apple’s OS, Darwin. (Probablly some sort of evolution joke there?) Like the FreeBSD Ports before it, it allowed System Admins and users to easily install Unix applications from the command line with a simple command or two. Macports brings that all to OSX and is an essential part of making it a true Unix operating system.
Installing Mac Ports:
Step One: Install XCode
If you have the original install disc, a Tiger Upgrade disc, or even Leopard pop it in your drive and run Optional Installs. Note that in the default view of the OS disc you need to scroll down to find this file. Apple has done a pretty good job trying to keep things easy and unconfusing, but it took me about thirty Tiger upgrades before I noticed that the window scrolled down.
If for some reason you do not have this disc, never fear. Xcode can be downloaded for free from the Apple Developer Connection. You will need to sign up for ADC, but that is not a big deal. It’s 888MB in size so the download may take a while.
Step Two: Installing MacPorts
Grab the MacPorts installer from this page. If you’re running OSX 10.4 or higher you want to get MacPorts-1.5.0-10.4.dmg. This is a very small install as it’s actually all text files. Despite that it may seem like it takes a while to install. Simply continue through all the prompts until it’s done!
This is where things may get a little scarey. We need to use the Terminal or Command Prompt to edit a file called .profile in your user directory.
Open up Terminal. It’s hidden under Utilities in your Applications Folder. You can also get to it by typing term into Spotlight and clicking it under applications.
Type (or cut and paste) /Applications/TextEdit.app/Contents/MacOS/TextEdit .profile
Make sure to get the period before profile or this will not work.
You should see a less pretty version of the above.
You can also type: env
Look for the line that says: PATH=/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin (or really similiar)
If both of these are there then you’re good.
Step Four: Telling X11 about MacPorts (Optional)
This step is Optional but may make X11 a little easier to use in the future.
Type in: sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/X11/xinit/xinitrc
You’ll see a prompt asking for your password. If your user is the Administrator (it is usually by default) type in your login password.
Right before the line that says userresources=$HOME/.Xresources, type in: source ~/.profile
Save and Exit
Step Five: Update MacPorts (Optional)
At this point you’ve officially got MacPorts installed. But one last thing may need to be done.
Type: sudo port -d selfupdate
Enter your password again if it asks. A lot of test will scroll by, this will update MacPorts to the latest version if needed.
Step Six: Installing Ports
At this point the instructions are going to become vauge. If you got this far you probably had a specific port or package you wanted to install. Refer to the instructions of that application for specific install directions.
You can also use the command: port search
Once you’ve found the package name, install it by typing: sudo port install
If you get this error message: Error executing darwin_8: invalid command name “configure.compiler”
You need to reinstall XCode again.
If you get: state is not writable – check permission on port directory
You need to run the install as Administrator by using the sudo command at the begining.
Please leave comments and let me know if you want more tutorials like this.
*update* These directions are Tiger only. Leopard does not work, see the comments below.