It’s safe to say that the Apple ecosystem brought “app stores” to the mainstream. Before the introduction of the iPhone, buying digital software was often full of trials like submitting your payment to the developer’s website, waiting for a license key by email, and negotiating refunds.
You’d be forgiven for thinking that free and open source software (FOSS) is rare on the Mac, given Apple’s approach. In reality, the Mac is an excellent host for many of the community’s best free tools .
MacPorts is your “app store” for all this great software. Let’s take a look at how it works.
What Is MacPorts?
MacPorts is a package system for Macs. It’s very similar in function and use to the Red Hat Package Management (RPM) system and Advanced Package Tools (APT), which install DEB packages on Linux . Actually, it descends from the Ports system of FreeBSD.
Did you know Mac OS X started its life as a fork of FreeBSD called Darwin? Even today macOS has a solid UNIX-based foundation . This makes it very easy for developers to create a “port” of free software applications that will run on Macs.
MacPorts is the collection of that software, as well as the application that acts as a “store” or installer. In the FreeBSD world, the ports system helps users compile software from source:
- First, you fetch the ports collection, which is a huge number of configurations that describe applications and how to build them (including their dependencies). These are stored in your “/usr/ports” directory with a sub-directory for each port.
- Then you navigate to an application’s directory and issue to the “make install” command. The makefile literally builds the application from scratch: downloads the source code, compiles it, and configures it. The below image shows the contents of the port for KDE’s Amarok music player. You can even re-build the entire system from source with the “make world” command.
MacPorts follows this model. When you to select an application, the system will download it, compile it, and install it (again, including dependencies) on your Mac.
What Kind of Ports Are Available?
The MacPorts repository is full of all the same great open source applications you’ll find on Linux and related operating systems. If you’re familiar with Linux, there’s a good chance your favorite apps are among the 19,000+ available. Not only that, but they’re installed and maintained in a very Unix-like but still integrate nicely with macOS.
You’ll find some apps that are as good or better than commercial counterparts, such as the Emacs and VIM text editors . Others are arguably not as good but are still free.
If you’re looking for a particular program, try browsing at the link above or using the “port search” command (more on that later). Some of the software available includes:
- Servers: Standard FOSS server stacks including AMP (Apache web server, MySQL/Maria database server, and PHP/Python ), SSH, SAMBA, and and the BIND DNS server are available.
- GNOME/KDE Software: If you’re a desktop Linux user, take your pick from among the 325 GNOME ports and 274 KDE ports . From GNOME’s GnuCash to KDE’s Amarok, you won’t miss anything. Other desktops including XFCE and NextStep are also represented.
- Text Processing: If you’re coding, doing technical writing, or you just enjoy the zen-like experience that working in plain text offers, you’re covered. Text editors like the aforementioned Emacs and VIM are available for authoring, while applications and systems like Multimarkdown , DocBook, and LaTeX help publish it in a pretty format.
- Programming Languages: Standards like Python, PHP, Ruby , and are all accounted for, as are newer or more specialized languages like CoffeeScript , Lua, and Kotlin . Other tools like development environments (e.g. Qt Creator for the Mac) and compilers (gcc) are present as well.
Installing and Setting Up MacPorts
Since MacPorts will be compiling software on your machine, you’ll need some developers tools. Don’t worry, the app will do all the heavy lifting, so you won’t have to learn any nerd-speak (unless you want to, in which case start here ). You’ll first need to install Xcode, which is a simple grab from the App Store.
Next, open the Terminal app and run the following command, which will pop a dialog for you to download and install Xcode’s command line tools:
Getting the MacPorts front-end is as simple as downloading the app for your version of macOS (as shown in the below image) from the site’s install page.
It comes as a PKG file , so you’ll see the familiar wizard pop up to walk you through the install. You can click Continue through these screens, as there’s really no choices for you to make.
Once installed, you won’t see anything appear in the Applications folder like your average Mac program. The port search application is a command-line program, so you’ll need to fire up Terminal (or your favorite Mac-based terminal app ) to get started.
The first thing to do is to update the collection of ports (which, again, are descriptions of available apps):
sudo port selfupdate
Installing Your First Port
Once updated, you can start looking for applications to install. From the terminal, you can search for keywords with the port search command. Suppose we want to find an old-school dual-pane file manager. Similar items in the App Store are either commerical or have in-app purchases. Let’s try to find a free one with the following command:
port search 'file manager'
Picking through these results, you’ll find Krusader. This super-useful tool for Linux is indeed dual-pane, and adds extra functions like file synchronization and archive management. To install it, run the following:
sudo port install krusader
You’ll need to enter your admin password, since you’re running the “sudo” command. The install will take a while. (Note all the dependencies, upwards of 100, as shown in the below image.)
Before you run off and grab a coffee, take a moment to watch the automatic download and build of your app. It may seem like a lot of techno-babble filling up the terminal window (in fact, the output from these builds is blessedly compact). But if you look closely it’s easy to make out what’s happening for each port.
- First off, MacPorts determines in which order it should install the ports based on their dependencies.
- For the each one, MacPorts will download its source code archive from the server.
- It will also verify that it has the right one by comparing the archive’s checksum against the port description.
- Then, it unpacks the port’s source code.
- If there are configuration scripts to run before the build, those go next.
- Building the software involves compiling all the source code into something the Mac can execute.
- Once the build completes, the resulting executable code is placed in its proper directory, then registers the app with the system.
- Finally, MacPorts will clean up all the source code. These per-port steps are shown for Krusader in the below image.
Now you’ll find a new subfolder within Applications titled “MacPorts” containing your app (in this case, Krusader under the “KDE4” folder). Fire it up and stick it to the Dock, just like any other app. You can also launch it using Spotlight .
Updating and Deleting Your Ports
To update your ports collection, use the command we used at the very beginning (this will also update the MacPorts application itself):
sudo port selfupdate
Then you can list any out-of-date ports with this command:
To actually execute the upgrade on these, use this:
sudo port upgrade
The upgrade subcommand will run through the same steps as install, except it will overwrite the older versions. If you tried out an app and want to delete of it, the uninstall subcommand will do the trick (Pallet, shown below, is a MacPorts GUI I installed which seems to be broken):
sudo port uninstall pallet
Get Your macOS Open Source Goodness With MacPorts
The MacPorts project unlocks many of the great things about open source software, including the community. You have full access to all the code, in a format that’s easy to install and maintain.
What do you think? Does the command line interface put you off? Which apps have you installed so far? Let us know your thoughts below in the comments!
Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.