The term *package manager* is a generic phrase for software meant to install, upgrade, and uninstall applications. Commands like `dnf` or `apt` on Linux, or `pkg_add` on BSD, or even `pip` on Python and `luarocks` on Lua, make it trivial for a user to add new applications to their system. Once you've tried it, you're likely to find it hard to live without, and it's a convenience every operating system ought to include. Not all do, but the open source community has a tendency to ensure the best ideas in computing are propogated across all platforms. There are several package managers designed just for macOS, and one of the oldest is the

MacPorts

project.

Darwin and MacPorts {#_darwin_and_macports}

After Apple shifted to UNIX at the turn of the century, they essentially built a UNIX operating system called Darwin. As a result, a group of resourceful hackers promptly began work on a project called OpenDarwin, with the intent of creating an independent branch of Darwin. The hope was that OpenDarwin developers and Apple developers could work on related code bases, borrowing from each other whenever it was deemed useful to do so. Unfortunately, OpenDarwin didn't gain traction within Apple and eventually

came to an end

. However, the OpenDarwin package manager project,

MacPorts

, is alive and well, and continues to provide great open source software for macOS.

MacOS comes with a healthy set of default terminal commands, some borrowed from GNU, others from BSD, and still others written especially for Darwin. You can add new commands, as well as graphical applications, using MacPorts.

Installing MacPorts {#_installing_macports}

First, get the version of macOS you're currently running:

----[source.bash] $ sw_vers -productVersion 10.xx.y

Once the installer has downloaded, you can double-click to install it, or install it using a terminal:

----[source.bash] $ sudo installer -verbose \ -pkg MacPorts-2.6.3-10.14-Mojave.pkg -tgt /

Load your new environment:

----[source.bash] $ source ~/.bashrc

Using MacPorts {#_using_macports}

Some package managers install pre-built software from a server onto your local system. This is called *binary installation* because it installs code that's been compiled into an executable binary file. Other package managers pull source code from a server, compile it into a binary executable on your computer, and then install it into the required directories. The end result is the same: you have the software you want.

The way they get there is different.

There are advantages to both methods. A binary install is quicker, because the only transaction required is copying files from a server onto your computer. This is something

Homebrew

does with its "bottles", but there are sometimes issues with

non-relocatable

builds. Installing from source code means it's easy for you to modify how software is built, and where it gets installed.

The typical workflow is to search for an application, and then install it.

List all ports {#_list_all_ports}

If you don't know what you're searching for in the first place, and you just want to see all avairable ports, use the `list` subcommand:

----[source,bash] $ sudo port list

Search for an application {#_search_for_an_application}

If you have a specific command or application you know you need to install, first search for it to ensure that it's in the MacPorts tree:

----[source.bash] $ sudo port search parallel

You can make your searches "fuzzy" with common shell wildcards. For instance, to search for `parallel` only at the start of a name field:

----[source.bash] $ sudo port search --name --glob "parallel*"

This displays important metadata about each application, including a brief description of what it is, and the project homepage in case you need more information. It also lists dependencies, which are *other* ports that must be on your system in order for this one to run correctly. Dependencies are resolved automatically by MacPorts, meaning that when you install, for example, the `parallel` package, MacPorts also installs `perl5` if it's not already on your system. Finally, the License and port maintainer is listed.

Install a package {#_install_a_package}

When you're ready to install a package, use the `install` subcommand:

----[source.bash] $ sudo port install parallel

Applications installed by MacPorts are placed into `/opt/local`.

View what is installed {#_view_what_is_installed}

Once a package has been installed on your system, you can see exactly what's been placed on your drive using the `contents` subcommand:

----[source.bash] $ sudo port contents parallel /opt/local/bin/parallel

Uninstall {#_uninstall}

Uninstall a package with the `port uninstall` command:

----[source.bash] $ port uninstall parallel

Proxied content from gemini://sdf.org/klaatu/geminifiles/macports.gmi (external content)

Gemini request details:

Original URL
gemini://sdf.org/klaatu/geminifiles/macports.gmi
Status code
Success
Meta
text/gemini
Proxied by
kineto

Be advised that no attempt was made to verify the remote SSL certificate.