C.W.K.
Stream
Lesson 02 of 05 · published

Installing MacPorts

~10 min · macports, installation

Level 0Newbie
0 XP0/55 lessons0/16 achievements
0/80 XP to next level80 XP to go0% complete

MacPorts installs from a signed .pkg installer specific to your macOS version. Unlike Homebrew's curl-pipe-bash workflow, MacPorts wants the formal installer route — partly because it has to set up the /opt/local prefix with strict root permissions and a specific user/group structure.

The prerequisite is the Xcode Command Line Tools. MacPorts compiles from source, so you need a working toolchain. xcode-select --install handles that.

After the installer finishes, the very first thing to do is sudo port selfupdate. This fetches the latest port definitions (the equivalent of brew update). MacPorts' port tree updates frequently, and a fresh install ships with whatever was current on the day of the .pkg release — which can be months old.

Code

Install MacPorts (4-step ritual)·bash
# 1. Xcode Command Line Tools (required for source builds)
xcode-select --install

# 2. Download the .pkg matching YOUR macOS from:
#    https://www.macports.org/install.php
#    (Pick the right one — Sequoia/Sonoma/Ventura have separate builds.)

# 3. Run the installer (GUI). It places binaries under /opt/local/bin.

# 4. Verify + update the port tree
port version
# Version: 2.12.4

sudo port selfupdate
Confirm PATH (usually automatic)·bash
# The installer adds /opt/local/bin to PATH via /etc/paths.d/MacPorts
cat /etc/paths.d/MacPorts
# /opt/local/bin
# /opt/local/sbin

# Restart your terminal or 'source ~/.zprofile', then:
which port
# /opt/local/bin/port

External links

Exercise

If you want to follow along with the rest of this track, install MacPorts from the .pkg, run 'sudo port selfupdate', and confirm 'port version' returns 2.12.x or newer. Even if you decide to stick with Homebrew, having MacPorts installed gives you a fallback for the rare port that doesn't exist in homebrew-core.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.