This MacOS Package Manager Will Make You Smile

Homebrew, the missing packages manager for macOS (or Linux)
Reading time: 3 minutes

MacOS has an app store, but does that contain all the software you need? No. Especially when you’re an advanced user, like a developer or a scientist, you’ll find that MacOS lacks a good package manager. You want something like yum, or apt-get. Something with which you can install anything with a single command. No downloading and extracting, manual compilation, or “Slide to install”. This is where Homebrew comes in, the ultimate macOS package manager!

What is Homebrew?

Homebrew is the missing package manager for macOS. At least that’s their slogan… but it’s so true! Homebrew allows you to install the stuff that Apple doesn’t offer you. Have you ever needed the latest version of Python, xz, wget, tmux, FFmpeg, untar, <insert any piece of software here> on your Mac?

The list of packages offered is almost endless, go see for yourself (alphabetically sorted). Or check out this list ordered by the number of installs.

And these are just the command line tools and libraries, also called “formulae”. But there are also “Casks”. With a cask, you can easily install GUI software from the command line. No more “drag to install”. Here’s the list of casks that are available today.

Installing Homebrew

Installation couldn’t be simpler. Paste the following command in a terminal prompt and the installer will download and execute. The script explains what it will do and then pauses before it does it.

/usr/bin/ruby -e “$(curl -fsSL"

(if this is broken up in multiple lines: it should all be on one line after you paste it in your terminal)

Using Homebrew

Well, that was easy. Now let’s install something.

You may want to have unrar on your system, it’s a nice and small decompression tool that’s missing on the Mac:

$ brew install unrar

Bam! Done.

Want to try Chromium, the stripped, open-source version of Google Chrome? Here you go:

$ brew cask install chromium

You now have an extra browser at your disposal.

Want to update all your packages to the latest versions?

$ brew upgrade

Or a specific package:

$ brew update unrar

Uninstall a package with:

$ brew uninstall <package>

You can search for casks and formulae using brew search. For example:

$ brew search firefox

Will return:

==> Casks

See that? You can install 6 versions of Firefox. How awesome is that?

Where do packages get installed?

If you like to know a little more about how brew works, read on. There’s no magic going on and it’s easy to modify formulae on your system. You can inspect and edit a formula yourself simply by using brew edit <formula>. Let’s look a the formula of the xz compression tool with brew edit xz:

The formula for the xz compression tool

As you can see, there is a description, link to the homepage, the download URL of the tarball, an extra mirror URL and a sha256 hash used to verify the integrity of the download. There are no dependencies, but if there were they would be listed as well.

Next, there is the install function. It contains a couple of system calls. If you’ve ever compiled source code yourself, the ./configure, make , make install riddle will look familiar. It’s simply doing all the stuff you would otherwise do by hand.

After compilation, brew places the software in what is called the Cellar. Every package ends up in a directory structure that looks like:/usr/local/Cellar/<package>/<version>/

To make this more concrete, the xz binary on my system is installed in: /usr/local/Cellar/xz/5.2.4/bin/xz

If you enter which xz you’ll discover that xz is found in /usr/local/bin/xz . What happens is that brew creates a symlink to the latest version in /usr/local/bin. You can link and unlink formulae yourself with brew link and brew unlink, if you want to disable a piece of software for whatever reason without completely uninstalling it.

Works on Linux too

You can install Homebrew on Linux too. But why would you need it, if your distro already comes with a great package manager? Well, one reason can be that Homebrew will install the packages without needing superuser permissions. Another reason can be that Homebrew might have packages that your distro does not have. And the most important reason is that Homebrew packages are almost always up-to-date, meaning that you’ll usually get the latest releases of the stuff you install.

Further reading

If you got this far, I think you will be interested in the following article as well:

Liked this article? Please share it with others:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.