Mac Homebrew
Homebrew is a package manager that helps you install software programs for the command line. Here is all about Homebrew, what to use it for, covering alternatives, amount of time needed for installation, and Homebrew terminology. This article offers explanations that are missing from the official Homebrew site (brew.sh).
See Install Homebrew for installation instructions. You'll need to use the Mac Terminal to install Homebrew.
Before you get started
You'll need a terminal application to install Homebrew. Apple includes the Mac terminal but I prefer Warp Terminal. Warp is an easy-to-use terminal application, with AI assistance to help you learn and remember terminal commands. Download Warp Terminal now; it's FREE and worth a try.
Steps
Here are steps to install Homebrew:
- Check macOS and update macOS.
- Check for Xcode CLT.
- Install Homebrew.
- Update the shell configuration (Mac M1 M2 M3).
- Install packages for software tools or languages you need.
What is Homebrew
Homebrew is a package manager for macOS (and Linux, too). It is one of the first tools you'll need to set up a local development environment for programming on a Mac. Use it to install (and remove) software programs for the terminal, or command line. It is like an app store for programming tools (but everything is free). MacOS includes some pre-installed programming languages and command line utilities but most work requires newer versions of languages and tools not provided by Apple. Get what you need with Homebrew. Almost every useful open source program (or "package") is available through Homebrew, with a single tool to install and manage each one. Homebrew's biggest drawback? A cute terminology of kegs, casks, bottles, and other beer-themed terms, explained here.
Mac M1, M2, M3 (Apple silicon)
Homebrew added support for Apple silicon (the Mac M1, M2, M3 chips) beginning with the release of Homebrew 3.0.0 in February 2021. On Apple silicon, Homebrew installs files into the /opt/homebrew/
folder, which is not part of the default shell $PATH
. You'll need to configure your shell environment so Homebrew packages are found and take priority over pre-installed tools.
If you have an older Intel Mac, Homebrew installs files into the /usr/local/
folder, which is already configured for access by the shell with the macOS default $PATH
environment variable. Mac Intel installation is easier because there's no need to configure your shell environment. Homebrew packages are found automatically. However, the Homebrew team was criticized for using the /usr/local/
folder because other programs might install software into the folder, overwriting Homebrew packages. With the release of version 3.0.0 for Apple silicon, the Homebrew team responded and changed the default folder, adding an installation step that requires a change to the shell environment. Experts argue that configuring the shell environment is basic knowledge, even though it will be inconvenient for beginners.
Homebrew and version managers
Understand the difference between Homebrew and software version managers. Homebrew is a package manager that adds a single version of a language such as Python or Ruby to the Mac. It can install one (and only one!) version of a language (the latest version). Installing a language with Homebrew is fine for a student or casual user. However, most professional developers will use Homebrew to install a software version manager that can install and switch between multiple versions of a language. Most developers develop and maintain several applications and each may depend on a different language version. If you are working with multiple languages and multiple versions (for example, Ruby and Node), consider using Homebrew to install Asdf on Mac. If you’re on a team with a complex project environment (for example, Ruby, Node, Redis, and PostgreSQL all in one project), you might be asked to use Docker, which is a container system that sets up multiple development environments (like having multiple computers with different configurations).
Alternatives to Homebrew
MacPorts, Fink, pkgin, and Nix are alternatives to Homebrew on macOS. On Linux, developers use apt-get or Homebrew. On Windows, developers use Chocolatey to install programs from the NuGet package library (they also use apt-get under WSL, the Windows Subsystem for Linux).
On the Mac, MacPorts requires more technical skill and requires sudo
or root access (Homebrew aims to be friendlier and more secure for non-expert users). MacPorts is more independent of macOS, ignoring many of the system libraries and software that are already available in macOS, avoiding dependence on Apple's update schedule (Homebrew relies on macOS system libraries for faster set up). MacPorts is a better choice for a multi-user Mac, should more than one developer be using the same Mac. Fink is the oldest of the Mac package managers and modifies the Linux apt-get package library. Fink is often not up to date with the latest macOS version. Pkgin installs binaries from the NetBSD (Unix) pkgsrc repository and requires sudo
or root access, making it more suitable to a skilled Unix user. Some developers on large teams use the Nix package manager. Nix is very complex but creates fully isolated, reproducible development environments.
Homebrew is the most popular package manager because it is easiest to use and frequently updated.
How long does Homebrew take to install
First time users will ask, how long does it take to install Homebrew? On a 2021 Mac M1 Mini, with a 100Mbps Internet connection:
- Homebrew installation takes 2 to 15 minutes.
It's significantly slower on Mac Intel over a slow Internet connection. Installing packages can take a few minutes, especially if a pre-built binary is not available and the software package must be compiled during the installation process.
Homebrew terminology
You'll either love or hate Homebrew's cute beer-brewing theme. Part of using Homebrew is understanding its beer-themed terminology. Here are terms; click for meanings.
formulae
A Homebrew formula is a Ruby script that controls the installation of a package. Formulae are contributed by people who maintain software packages. You don't need to know how to write a formula to use Homebrew; you just enter the command brew install <formula>
. The homebrew-core repository contains over 4000 packages. Each formula lists the location of the package's source archive and includes directives to build the software from the archive.
tap
A Homebrew tap is a repository that contains Homebrew formulae used to install packages. The default Tap is on GitHub as homebrew-core. The brew tap
command allows a developer to use formulae from their own repository without submitting anything for approval by Homebrew.
keg
A Homebrew keg is the folder that contains a specific version of a package that has been installed by Homebrew. The path to the keg contains both the package name and version number, for example /opt/homebrew/Cellar/tree/1.8.0
. For most packages, Homebrew creates a symbolic link ("alias" or symlink) from the keg to the /opt/homebrew/bin/
directory so entering the package name as a command will run the installed version from the keg. A few packages are installed "keg-only" which means no symlink is created because the package may conflict with a pre-installed package from Apple. Keg-only packages are usually dependencies needed to install or run other Homebrew packages, avoiding conflicts with macOS system software.
bottle
A Homebrew bottle is a pre-compiled package, sometimes called a "binary." Installation is faster with a pre-compiled package.
cellar
The Homebrew cellar is the directory where Homebrew stores packages. It is the folder /opt/homebrew/
on Apple silicon machines and /usr/local/
on Mac Intel.
cask
A Homebrew cask is like a keg, but contains macOS GUI applications installed from the command line. Casks are not very popular but provide a mechanism to automate the installation of GUI applications from a script or the command line.
mxcl
Homebrew's mxcl is Max Howell, the creator of Homebrew. Not really a term, but good to know.
What's next
My mac.install.guide is a trusted source of installation guides for professional developers. Take a look at the Mac Install Guide home page for tips and trends and see what to install next.