How to Install DarwinPorts
Sunday the 14th of September, 2008

    How to Install DarwinPorts

    1. Install Xcode Tools

    1. Download and install the latest version of Xcode Tools do not install an older version from the OS X 10.4 install disk or some ports may fail to install.
    2. Run the binary installer.
    3. Click Customize, expand the Applications category and click the checkbox beside X11 SDK to add it to the default items.
    4. Click Install to install Xcode Tools and the X11 SDK.

    Notes: Xcode Tools is neither installed nor updated via the Software Update utility.

    2. Install XWindows (X11)

    On OS X 10.4, Apple's X11 is an optional install (DarwinPorts' X11 package is not recommended at this time). If the application X11 is not present in /Applications/Utilities:

    1. Insert the "Mac OS X Install Disk 1" and run the package named "Optional Installs".
    2. At the software selection window expand the Applications categoty and click the checkbox beside X11 (and nothing else).
    3. Click Install to install X11.
    4. Drag the /Applications/Utilities/X11 icon to your dock - you must open X11 before launching an X11 application.


    • XWindows (X11) is required for many DarwinPorts apps and it is highly recommended that you install it even if you don't plan to run X11 apps immediately.
    • The X11SDK is also required to run X11 software, but it is installed by default during the Xcode Tools install above. If you wish to check to see if X11 (X11User) and X11SDK are installed, look in /Library/Receipts for the files X11User.pkg and X11SDK.pkg.

    3. Set the shell environment

    Setting the Unix shell environment is critical for DarwinPorts to function.

    Requirements for the DarwinPorts' shell environment

    The DarwinPorts binary installer places a .profile file in your home directory (view files preceded by a dot with 'ls -a'). The contents of this ~/.profile file adds the DarwinPorts paths in front of the standard Unix paths for the default BASH shell. This is done so that if you have utilities or libraries from both DarwinPorts and OS X's standard install, the DarwinPorts libraries will be run instead of the ones provided by Apple.

    export PATH=/opt/local/bin:/opt/local/sbin:$PATH

    You'll need to add this variable to your ~/.profile to run X11 applications:

    export DISPLAY=:0.0

    So a basic ~/.profile file will look like this:

    export PATH=/opt/local/bin:/opt/local/sbin:$PATH
    export DISPLAY=:0.0

    Important Notes:

    • To understand why DarwinPorts libraries are often installed when Apple has provided one, see section "Why is DarwinPorts using its own libraries?" in the FAQ.
    • Changes to ~/.profile do not take effect on the current shell session - they take effect on new sessions so open a new shell session and type 'env' to see the path and variable changes.
    • Other profile files may take precedence over ~/.profile. If you are using one of the following profile files in your home directory, you will need to merge the contents of it into ~./profile, or vice versa because the shell will ignore one of them:
      • ~/.bash_login
      • ~/.bash_profile

    Verify the shell environment

    To verify that your ~/.profile has set your shell environment:

    1. Open a new terminal window
    2. Type the command: env

    Check to make sure the reported path begins with the DarwinPorts' paths as show above.

    Sample output of command env:


    Options for the DarwinPorts' shell and X11 environment

    To set a default editor for use with the port command (e. g. 'port ed mysql5'), add a variable EDITOR with the path of your favorite editor to the ~/.profile file.

    export EDITOR=/usr/bin/pico

    A sample ~/.profile with optional EDITOR variable set:

    export PATH=/opt/local/bin:/opt/local/sbin:$PATH
    export DISPLAY=:0.0
    export EDITOR=/usr/bin/pico

    To launch X11 apps directly from an X11 window (instead of a terminal window), you need to have the DarwinPorts paths imported into X11 sessions when they are opened. This is a two step process.

    First, tell X11 about your .profile file by editing the file /etc/X11/xinit/xinitrc and add this line near the top.

    source ~/.profile

    Now finish by making any subsequent X11 sessions opened using the menubar respect your .profile.

    1. Open X11 and select "Customize Menu ..." from the Applications menu.
    2. Double-click the menu item "Terminal" and change: xterm to xterm -ls
    3. Click "Done" to save the change.

    4. Install DarwinPorts

    Install DarwinPorts using the binary installer (to /opt/local/ only)

    1. Download the latest DarwinPorts .dmg disk image, currently version 1.4.0.
    2. Run the binary installer.
    3. Perform the default -easy- install.


    • A DarwinPorts' selfupdate (see below) will automatically update to the latest release if the binary .dmg image is behind the latest released tarball.

    Install DarwinPorts from source (to any path except /usr/local/)

    1. Download and unzip the latest DarwinPorts tarball from the DarwinPorts download area.
    2. Perform these commands in a terminal window.
      cd ~/DarwinPorts-1.4.0/
      sudo make install


    • To see why /usr/local is not a viable install location for DarwinPorts, see the DarwinPorts FAQ

    Install DarwinPorts that you downloaded

    5. Update DarwinPorts via selfupdate

    The 'port selfupdate' command must be run after a new DarwinPorts install, and frequently thereafter. The command updates DarwinPorts with the latest port revisions, and, if necessary, updates DarwinPorts to the latest release.

    1. Open a terminal window.
    2. Execute the DarwinPorts selfupdate command.
    sudo port selfupdate

    or for verbose output:

    sudo port -d selfupdate