Why Homebrew is Installed in /opt/homebrew on Apple Silicon Macs

apple-siliconhomebrew

The Homebrew installation page says:

This script installs Homebrew to its preferred prefix (/usr/local for
macOS Intel, /opt/homebrew for Apple Silicon and
/home/linuxbrew/.linuxbrew for Linux) so that you don’t need sudo when
you brew install. It is a careful script; it can be run even if you
have stuff installed in the preferred prefix already. It tells you
exactly what it will do before it does it too. You have to confirm
everything it will do before it starts.

Why does Homebrew choose /opt/homebrew as the installation prefix for Apple Silicon Macs instead of /usr/local like it does for Intel Macs?

Best Answer

I would highly recommend checking out the original Homebrew discussion here. I'll summarise a few points from it below.

The default prefix before Apple Silicon (/usr/local) was chosen for a few reasons:

  • It's already in PATH. This means that tools installed with homebrew can be accessed without any need to change anything.
  • Quite a few build systems already look in /usr/local, so libraries installed with homebrew can be used by non-homebrew tools.

The Apple Silicon transition came with a change in the default Homebrew prefix. Some of the reasons for this included:

  • /usr/local is also used by other tools, not just Homebrew. This can lead to potential conflicts.
  • Installations in /opt/homebrew for Apple Silicon and /usr/local for Rosetta 2 can coexist.
  • Homebrew tools might not always want to be used by default. A different prefix would make this easier.

There was also an interesting article a while back about some of the potential security risks with /usr/local that you might find interesting.

Other macOS package managers were already using different prefixes (MacPorts with /opt/local and Fink with /opt/sw). MacPorts listed some reasons why they don't use /usr/local here, and Fink has here.

Just to note, although not recommended, Homebrew can technically be installed anywhere. However, pre-built bottles/binaries are only available on the default prefix.