Skip to main content

Homebrew

Minimalist software management for POSIX systems

2019-06-15 — 2026-11-17

quality 7.7

In Which a Terminal Is Fed a Curling Script to Summon Packages, Ffmpeg-Full Is Sought for Its Illicit Codecs, and Libpng Is Tracked Through Dependency Chains to Purge the Machine of Unseen, Unwanted Orphans.

compsci
computers are awful
POSIX
premature optimization
Figure 1

homebrew is a good dependency manager for apps not packaged by the system.

1 Installation

Classic install like this:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

On macOS, there is, since version 4.0, a .pkg installer. You might feel that installing that is more secure than the previous horrifyingly insecure method, but you know what? It’s all code written by strangers on the hostile internet and at least the former one reminds you what a security abyss this world is.

2 Rich media support

I want all the libraries that are too patent-encumbered to be bundled with whatever holier-than-me distribution I run. This means codecs and other content-related apps, e.g.

brew install libsamplerate libsndfile ffmpeg-full node pandoc webp libavif yt-dlp

The plain ffmpeg formula was slimmed down to a tiny handful of codecs that seem not to reflect anything interesting that anyone might need FFMPEG for. I imagine vanilla ffmpeg only concatenates markdown files or something at this point.

ffmpeg-full is the one with the delicious codecs that you know you want to use for all your video needs!1 It is keg-only, so its binaries are not on the PATH until I add $(brew --prefix ffmpeg-full)/bin myself. Codecs too non-free even for ffmpeg-full, such as fdk-aac, come from the homebrew-ffmpeg tap.

1 And also full of exciting CVEs. Watch out for videos from suspect sources.

3 Managing installed packages

If I want to know what I currently have installed, I can do:

brew leaves

To find out which of the packages I asked for are dragging in some unwished-for dependency I use the following command:

brew uses --installed --recursive libpng | grep -Fx "$(brew list --installed-on-request; brew list --cask)"

This one is if I’m worried about libpng hanging around looking suspicious and want to know everything that would break if I removed it. brew list --installed-on-request is the set of formulae I explicitly installed; it excludes casks, hence the brew list --cask. brew leaves --installed-on-request is similar, but omits anything another formula also depends on, so it gives a shorter list. The quoted "$(…)" passes the list to grep as one pattern per line.

To see the chain through which a given explicit package reaches the library:

brew deps --tree --installed bfg

It is a good idea to keep this list trim, in these days of copious zero-day exploits etc.

To list the orphans, i.e. packages that came in as dependencies but that nothing I actually asked for needs (any more):

brew autoremove --dry-run

Dropping --dry-run uninstalls them.

brew leaves --installed-as-dependency lists the top layer of orphans; autoremove also follows the tree down, catching the libraries that only those orphaned leaves needed. We can draw the tree for all orphans

brew deps --tree --installed $(brew leaves --installed-as-dependency)

The tree is bigger than the autoremove list, showing dependencies that something else still needs; only the ones autoremove --dry-run lists would be removed.