5  Homebrew

If you’re setting up a Mac for development, Homebrew (https://brew.sh) is an absolute must. Installing Homebrew is one of the first things I do after firing up a new computer:

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

As they describe it on their site:

Homebrew installs the stuff you need that Apple (or your Linux system) didn’t.

Until my (as of this writing) most recent computer setup, my mental model for what to install with Homebrew was restricted to the packages in Homebrew Core—its default formulae (packages) that can be installed through its default “tap” (i.e. by using brew install <formula>). But, this time around, my approach was something akin to Homebrew all the things!

5.1 How to install macOS apps with Homebrew

Y’know how you used to have to download apps from their websites, and drag them to the application folder or whatever? Yeah—turns out you can do pretty much all of that using Homebrew Cask.

For example, instead of downloading the Alfred app from its site, you can run the following from your terminal:

brew install --cask alfred

Homebrew’s cask tap provides “a friendly CLI workflow for the administration of macOS applications distributed as binaries.”

5.2 How to install fonts with Homebrew

This one damn near blew my mind: Yes, you can install fonts with Homebrew! Like installing macOS apps (Section 5.1), fonts are Homebrew casks (they live in Homebrew’s homebrew-cask-fonts repo). The first time you do this you will have to tap this collection of casks.1 To do so you’ll run the following:

brew tap homebrew/cask-fonts

Once you’ve done that, the “tap” is there for your future use, and you won’t have to run that command again. To install individual fonts, you’ll follow the brew install --cask <NAME OF THING HERE> you used for macOS apps. The font names are prefixed with font-. For example, to install Roboto, you’d run:

brew install --cask font-roboto

What fonts are in there? I don’t have an exhaustive list on hand, but the answer is a lot (just shy of 1,900 font casks in the directory as of this writing)! I’m pretty sure everything from Google Fonts is there, as are the Nerd Fonts. You can peruse available fonts with brew search font-. However, I usually just give installing the font with homebrew a try, and go from there.

5.3 How to have multiple installations of Homebrew

Homebrew works great with the Apple Silicon—i.e. newer Macs with arm64 processors—and gets installed natively to /opt/homebrew. However, there are some tools and applications that don’t yet support the arm64 architecture, and need Apple’s Rosetta (a translation environment) to follow the x86_64 instructions (i.e. the ones for the Intel architecture).

If it’s a whole application that needs to be run using x86, you can just select “Open using Rosetta” in the application’s info pane2, and move on your merry way. However, things get a little bit trickier if you’re dealing with something like a CLI tool (in my case, the Heroku CLI). 3 Hopefully this problem will soon be a thing of the past, but (for now) one way to address it is by having a second installation of Homebrew (an “Intel-emulated” version) on your machine that you run in a terminal using Rosetta .

This answer to “How can I run two isolated installations of Homebrew?” by Jacob Ford is quite complete, and worked perfectly for me. I’m basically repeating it here so I don’t forget what my setup is.

My starting assumptions are that you already have Rosetta and native (ARM) Homebrew installed, and that Homebrew is in its default location (/opt/homebrew).4

In a terminal run using Rosetta, install the Intel-emulated Homebrew to its default /usr/local:

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

Create an alias for this version of homebrew in your ~/.zshrc.5

alias oldbrew='arch --x86_64 /usr/local/Homebrew/bin/brew'

Make sure that the native Apple Silicon Homebrew is used by default by prepending it to your PATH. To do so add the following to your ~/.zshrc:

path=('/opt/homebrew/bin' $path)
export PATH

Confirm that things worked by running which brew and then which oldbrew (or whatever alias you used), which should return the paths I’ve commented out below:

which brew
# /opt/homebrew/bin/brew

which oldbrew
# oldbrew: aliased to arch --x86_64 /usr/local/Homebrew/bin/brew

Alternately, you can confirm by running:

  • brew --prefix (which should return /opt/homebrew), and
  • oldbrew --prefix (which should return /usr/local).

Because the native Homebrew comes first in your PATH, it will be used by default for commands that exist in both installations of Homebrew unless you specify that PATH=/usr/local/bin for the command. To make this easier, add another alias to your ~/.zshrc (I used Ford’s recommended ib, to stand for “Intel brew”), which you can then prepend to any Homebrew command to force it to use the Intel version.

alias ib='PATH=/usr/local/bin'

You can confirm that this worked by running ib which brew, which should return /usr/local/bin/brew.

5.4 How to install other stuff with Homebrew

In addition to Homebrew’s core formulae and casks, you can use Homebrew (i.e. the brew command) to install other third-party formulae (i.e. fonts, applications, etc.) using tap. The process is the same as the initial step of installing fonts with Homebrew (Section 5.2), since the fonts cask isn’t “on tap” by default. You add a new tap by running brew tap <user/repo>, and can then use brew install for the added formula.

Take, for example, Patrick Schratz’ rcli tool, which allows you to easily install and switch between multiple versions of R. The rcli installation instructions recommend the following for macOS:

brew tap pat-s/rcli
brew install rcli

In the first step, you’re adding the new tap, and, in the second, you’re installing rcli from that tap.

To remove an entire tap, you can run brew untap <user/repo>.

For details, see Homebrew Documentation - Taps.


  1. I may be messing up the beer-metaphor terminology here, but, don’t worry, the actual code syntax is correct.↩︎

  2. See Apple Support article on installing and using Rosetta for details.↩︎

  3. For instructions specific to using the Heroku CLI with Rosetta, see Beppe Catanese’s Deploy to Heroku From a MacBook M1: Heroku CLI or GitHubActions.↩︎

  4. If this is not the case, see Jacob Ford’s answer to the aforementioned question, which explains how to do both.↩︎

  5. I went verbose, and called mine oldbrew, since I didn’t trust myself with the one-letter difference between brew and brow Ford used in his answer.↩︎

  6. If you use Oh My Zsh, the brew plugin has some helpful aliases, including bubu (which updates Homebrew data, upgrades outdated formulae and casks, and runs cleanup).↩︎