HOWTO: Install into a custom location (i.e. not /opt/local)

$ ./configure --prefix=/Ports --with-tclpackage=/Ports/share/macports/Tcl

Without --with-tclpackage, parts of the MacPorts sytem gets installed into /Library/Tcl/macports1.0, which makes it difficult to run multiple version of MacPorts simultaneously (more info).

You may also want to

$ sudo ln -s /Ports/share/macports/Tcl/macports1.0 /Library/Tcl/macports1.0

so that "inferior software" can find the system's MacPorts installation (more info).

FAQ: Can't install package XXX

Recently, a lot more ports seem to not be specifying their dependencies correctly. This applies to several of the dependencies of subversion.

If you have trouble with ncursesw, try installing that by itself, and then installing subversion. (You may also have success installing sqlite3 first.)

If you have trouble installing curses, install coreutils first.

It may also help to install with verbose mode (-d) turned on--this may give some clue as to the cause of your problem.

FAQ: What's the difference between "installed" and "active" ports?

An "installed" port is compiled and ready to be activated, but is not necessarily "active"--only one version/variant of the same port can be "active" at the same time. For example, different versions (e.g. 1.2.3, 1.2.4) or variants (e.g. with X11 support, without X11 support) of the same package might be installed at the same time, but only one can be "active".

$ sudo port installed
...  
slang @1.4.9_0 (active)
sqlite3 @3.5.1_0
sqlite3 @3.5.2_0
sqlite3 @3.5.3_1
sqlite3 @3.5.4_0 (active)
tiff @3.8.2_1+macosx (active)
...

FAQ: What's the difference between "port list installed" and "port installed"

$ port list installed

This runs the "list" command over the pseudo-portname "installed", which expands to the installed ports. The output looks like this:

...
readline                       @5.2.007        devel/readline
slang                          @1.4.9          lang/slang
sqlite3                        @3.5.4          databases/sqlite3
...

Other useful pseudo-ports are "active" and "outdated".

$ port installed

This runs the "installed" command, which outputs the installed ports, indicating whether they are active or inactive. The output looks like this:

...
readline @5.2.007_0+darwin_9 (active)
slang @1.4.7_0
slang @1.4.8_3
slang @1.4.9_0 (active)
sqlite3 @3.5.4_0 (active)
...

HOWTO: Install a package

$ sudo port -c install jed

-c for autoclean mode--removes source/build files after installing (though not the binary package).

HOWTO: Turn on debugging/verbose mode

Add -d. e.g.

$ sudo port -d install ncursesw

or

$ sudo port -d selfupdate

HOWTO: Update/upgrade the "port" command itself

$ sudo port selfupdate

HOWTO: List outdated packages

$ sudo port outdated

HOWTO: Update/upgrade all outdated packages

$ sudo port -c upgrade outdated

-c to autoclean (remove build files)

(Adding -u to uninstall non-active ports doesn't work out the way you'd expect; it seems that other ports may have been built with dependencies on on the inactive port.)

HOWTO: Clean (remove) port build files

$ sudo port clean --all installed

Note that this removes build files only; it does not remove "inactive" ports (e.g. older versions, other variants of the package). See below for how to remove inactive ports.

HOWTO: Remove all inactive ports

How to get port list installed to show only one version of each package:

$ sudo port -u uninstall

You might need to add -f (to "force" the uninstall) if other "inactive" ports depend on it, though you might be able to fix this by rebuilding all the dependencies:

$ sudo port -fR upgrade $package

HOWTO: Remove port and dependents

$ sudo port uninstall --follow-dependents $package

ERROR: "Have you synced your source indexes?"

Run:

$ sudo port -v selfupdate

FAQ: What are the dependencies of a package?

i.e. what packages does a particular package need?

$ sudo port deps $package

FAQ: What is a particular package needed for?

i.e. what packages depend on a particular package?

$ sudo port dependents $package

FAQ: What files did a particular port install?

i.e. what are the contents of an already-installed package?

$ sudo port contents $package

FAQ: How to upgrade a variant-specific port?

This doesn't yet seem to be possible--see

<https://trac.macports.org/ticket/8221>

You may be able to upgrade without calculating dependencies:

$ sudo port upgrade -n ImageMagick

FAQ: How to search Trac for tickets entered you have an interest in

i.e. you either entered the bug, or added yourself as a cc on it.

HOWTO: Remove old versions of ports

$ sudo port clean --work --archive all

See https://trac.macports.org/wiki/Migration.