The MyMacPorts package, in the Development section of Self-Service, permits the creation and updating of a personal installation of MacPorts under the standard setup for MacOS X systems, without conflicting with the centrally-distributed instance of MacPorts. Your personal instance can include both end-user software and libraries.

Please see also:

MacPorts's home page and ports list
Astrophysics: MacPorts
Applications Setup
Care and Feeding of Shells
Portable Software


  • A full XCode Tools setup, including the command-line tools, plus a full X11 (Lion and older) or XQuartz (Mountain Lion and newer).

    • These are part of the standard Astrophysics (or Theoretical Physics) system setup.

  • The MyMacPorts package needs to have been installed from the Development section of Self-Service. This you have to do for yourself.

    • This also creates the target directory /Data/macports/$USER (where $USER is your login name), where your personal MacPorts installation will go, with correct ownership and permissions.


Do the following, in this order:

  1. Install the MyMacPorts package from the Development section of Self-Service (if you haven't already, or if you're doing a clean start).

  2. Do the following commands at the shell prompt:
    cd /Local/mymacportsmake world

    This should say at the end:

    *** Successfully made world ***

    If it doesn't, or if you get complaints during a build that gnutar can't create files, you've got an old version of MyMacPorts. Please see Clean Start for instructions on stripping out MyMacPorts and putting it back again: merely running port selfupdate is not sufficient to fix the problem, as it involves a change to the configuration files which port selfupdate cannot reach.

  3. Add appropriate directories to the front of the path in your current shell, to cause it to preempt the Centrally-distributed copy:

    • For readers in Astrophysics who are already using Applications Setup (qv), this is most easily done at the shell prompt by saying:
      Activate mymacports

      .... once per shell, at the command line.

    • Alternatively, e.g. in Theoretical Physics, define an alias, by putting something of the following form in your shell startup file:
      (csh/tcsh:)alias myports 'source /Local/mymacports/mymacports.csh '(sh/bash:)alias myports='source /Local/mymacports/mymacports.bash '

      .... and use that alias at the shell prompt (again, once per shell).

    • If you really must do this by hand in your shell startup files (which we don't advise: please see Environment Problems below), the appropriate paths are:

      .... for appropriate values of $USER.

  4. If you've used the Centrally-distributed copy of port in your current shell (before the above Activation, or equivalent), you may need to persuade said shell to forget about it before continuing:
    rehash  # csh/tcshhash -r # sh/bash

You will at this point have created an unpopulated instance of MacPorts, in the following directories:


It is up to you to populate it, and it is your responsibility to keep it up-to-date.


Once your MyMacPorts instance has been Activated in the current shell as described above, you can populate it, and examine its contents:

port install emacs +x11 # .... for example
port info emacs
port info emacs +x11
port info emacs +no_x11
port -q installed

The first example (on my system) took just under an hour from a standing start; including all dependencies and libraries, this consumed nearly 900MBytes of drive space. As your local set of installed dependencies gets fleshed out over time, later installation commands will tend to be progressively less time-consuming. (Please see also the speed tip in the Notes section below.)

Please note:

  • Some ports depend on others which conflict with the system setup. Please see Port Conflicts in the Notes at the end of this page for ways to deal with this.

  • If you get complaints about gnutar not being able to create files, you need to do a clean start.

The examples using port info between them demonstrate the effects of enabling and disabling available variants ("flavours") of a package. Try them, and note the differences in the Library Dependencies part of the respective outputs.

The last example is embedded (for readers in Astrophysics) in:

Activate help mymacports

.... which as a bonus also reports the version number of your personal MacPorts instance, and the datestamp of its PortIndex file. (Knowing whether or not MacPorts considers itself out-of-date is less useful in practice than knowing how out-of-date it is.)


If you are building software which uses the pattern of the "autotools" build system (sometimes described as "doing the configure/make/make install dance"), and you wish to link against one or more libraries from your personal MacPorts instance, you should use configure-time options of the following form:


.... where I've had to fold the last line at the backslash to fit this column. Please see Portable Software for more information about this.


This is your personal instance of MacPorts; it is your responsibility to keep it up-to-date. You will need to do this by hand, using the following commands:

port selfupdate
port upgrade outdated

Remember to do this early and often. It may take some time. Please consider it an investment of effort .... or as a hint to instead ask for the ports to be added to our Central-Physics distribution, which is updated and distributed on a weekly basis.

Clean start

On occasion, it will be wise to burn your MyMacPorts build to the keel and start again. To do this, and to then reinstall the same set of ports, first Activate your current MyMacPorts instance as above, then do something of the following form:

port -q installed requested | tee mymacports.requested

This puts a list of requested ports in the named file, plus version and activation information. (Remember, requesting a port will not only implicitly request all of its dependents, but also make note of which is which, for just this sort of exercise.)

cd /Local/mymacports
make uninstall # Burn to keel
make world     # New instance
/Local/mymacports/ mymacports.requested \\
| tee

The last incantation (which has had to be folded at the backslash to fit in this margin) processes the list of requested packages to produce a list of package installation requests, ready for port to act upon.

You should review the contents of, and possibly remove or update obsolete entries. In particular, if you're requesting FORTRAN libraries, please see the Note about FORTRAN in the Notes section first, and act on the suggestions.

Once you're satisfied with the build list, make it so:

port -F


Speed Tip

MacPorts will by default "clean" the build system of any port it installs, whether it's been requested directly, or is a dependency of one which has. This has the unfortunate side-effect that certain dependent ports (the GNU Compiler Collection comes most immediately to mind) sometimes end up being rebuilt multiple redundant times, and certain suites (eg the GNU Compiler Collection) take long enough to build as it is.

We have taken the liberty of assuming that you will value (re)build speed over drive space, and have on your behalf pre-edited the file:


to change the line which by default would read:

#portautoclean  yes

to instead read:

portautoclean   no

This is equivalent to specifying the -k ("keep") option to port, once and for all. If you really do need the space after all, you can always say port clean for yourself, at a time of your choosing. Please note, however:

  • Cleaning your MyMacPorts build tree will lose you some important diagnostic information.

  • Cleaning your MyMacPorts build tree will not reclaim more than 1% of the total filespace, unless you've built everything in creation.

  • If you're within 10% of completely flooding any partition on your system, your system will start slowing down noticeably, often when mds is indexing said partition. Likewise if any partition on your system has a spectacularly large number of files (over say a million), however small they may be individually.

    • If mds is turned off, you won't then be able to search your mailboxes in MaxOS X's mail client.

  • If any partition has less than 1% free space, MacOS X will get deeply distressed, after which merely slowing to a crawl will be the least of your problems.

Be Warned. End of sermon.


FORTRAN is provided in MacPorts via GCC (the suite) alongside gcc (the compiler); but it won't by default be called gfortran, but something like gfortran-mp-4.8. Some Fortran packages in MacPorts haven't necessarily been fully educated about this (PGPLOT comes to mind), and their configuration processes may in particular get confused on Astro systems by the presence of the version of gfortran which is installed to keep the StarLink suite happy. And that's before we consider your own code, or code from third parties.

The best way I've found to deal with this mess is to do the following preemptive strike:

Activate mymacports # (or local equivalent)
port install gcc
port select gcc

When I did this on my system this morning, I got the following result:

Available versions for gcc:
    none (active)

Then I did this:

port select gcc mp-gcc48
port select gcc

.... after which I saw this:

Available versions for gcc:
    mp-gcc48 (active)

... and saying "which gfortran" yielded the desired result:


Port conflicts

Some ports conflict with one another (emacs and xemacs come most immediately to mind); and some ports can depend on others (eg dbus) which conflict with the system.

  • If you get a conflict with the system, use port info desired-program to see whether there's a variant ("flavour") of desired-program which selects against the offending dependent.

    • For example, emacs has a variant dbus which adds a dependency on the dbus port, but which as it happens is now disabled by default.

    • Another instructive example is gtk2, which has the x11 variant preselected. Selecting the option +no_x11 at port install (or port info) time has the effect of enabling the quartz variant to provide the alternative Apple-flavoured GUI drivers.

  • In the particular case of dbus, I understand (but haven't yet personally verified) that the following workaround is now possible:

    port clean dbus
    port install dbus +no_root

    Carefully read any instructions the second incantation gives you, then proceed, with said instructions in mind.

Please let us know of any particularly egregious breakages, either by e-mailing us at the usual address, or by leaving a comment via the link at the foot of this page. We can then either document any workarounds for them, as for dbus above, or in the worst case document the problems' existence for other users' benefit.

Environment problems

Don't fall into the trap of adding the abovementioned bin and sbin directories to your path in your shell startup files. If perchance you install something in all innocence which breaks your login shell, or an update does something evil to your shell startup procedures, you will find it difficult to start up a shell to correct the situation.

  • It's safer to add an alias which will do this for you on request, then make said request by hand at the shell prompt. Please see Care and Feeding of Shells for suggestions.

Beware of fiddling with library or framework paths in your shell environment, especially in your shell startup files. This has been known to break some system programs in most mysterious ways.

  • If you find yourself unable to (eg) undo the lock on your own screensaver, contact us for assistance.

Categories: Apple | Astro software | Astrophysics | Development | Mac | MyMacPorts | OS X | Theory | macports