MacPorts Commands
This page provides a comprehensive guide to essential MacPorts commands for managing packages on macOS. MacPorts is a powerful package management system that simplifies the installation and management of software on macOS.
MacPorts Core Operations
These commands cover the fundamental operations for maintaining your MacPorts installation and installed packages.
---
syntax: bash
tags: [ mac, deps ]
---
# Update to the latest version of MacPorts, and sync the latest ports definitions:
sudo port selfupdate
# List all ports that are currently considered outdated:
port echo outdated
# Upgrade all currently outdated ports:
sudo port upgrade outdated
# List all ports that are currently *inactive*:
# (A port is usually deactivated when a newer version of it gets installed.)
port echo inactive
# Completely remove and uninstall all *deactivated* ports:
# This is very useful to do after upgrading all your outdated ports.
sudo port uninstall inactive
Installing and Uninstalling Ports
Learn how to install new software and remove existing packages using MacPorts.
# Install a particular port:
sudo port install <name>
# Install a particular port with full debug output:
sudo port -d install <name>
# Uninstall a particular port:
sudo port uninstall <name>
Managing Port States
Control the active and inactive states of your installed ports.
# Deactivate a currently active port:
port deactivate <name>
# Activate a currently deactive port:
port activate <name>
Port Information and Dependencies
Discover details about ports, their dependencies, and dependents.
# Search for a port
port search <name>
# View information about a particular port
port info <name>
# List the ports that have been explicitly requested by the user to be installed:
port echo requested
# List all ports that are currently installed:
port echo installed
# List the ports that this port depends on:
port deps <name>
# List the ports that this port depends on, then recursively list the ports
# that THOSE ports depend on as well:
port rdeps <name>
# List the ports that depend on this port:
port dependents <name>
# List the ports that depend on this port, then recursively list the ports
# that depend on THOSE:
port rdependents <name>
Port File System Operations
Access and manage files related to a specific port.
# List the files installed by a particular port:
# (Only works for currently installed ports.)
port contents <name>
# View a ports' notes, if any (these are usually displayed right after a port
# is installed):
port notes <name>
# Print the path to a port within the ports tree:
port dir <name>
# Print the path to the archive used to activate a given port:
# (Only works for currently installed ports)
port location <name>
# Print the path to a ports' Portfile:
port file <name>
# Print the path to the working directory for a port, if it exists:
port work <name>
Cleaning and Maintenance
Keep your MacPorts installation clean and efficient.
# Completely clean out all temporary assets of a port, such as build files,
# the working directory and any downloaded archives:
sudo port clean -f --all <name>
Getting Help
Access documentation for MacPorts sub-commands.
# View help on a sub-command:
port help <command>