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:/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./opt/homebrew
for Apple Silicon and/usr/local
for Rosetta 2 can coexist.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.