Instructions for a supported install of Homebrew are on the homepage.
The script installs Homebrew to its default, supported, best prefix (/opt/homebrew
for Apple Silicon, /usr/local
for macOS Intel and /home/linuxbrew/.linuxbrew
for Linux) so that you don’t need sudo after Homebrew’s initial installation when you brew install
. This prefix is required for most bottles (binary packages) to be used. 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.
The macOS .pkg
installer also installs Homebrew to its default prefix (/opt/homebrew
for Apple Silicon and /usr/local
for macOS Intel) for the same reasons as above. It’s available on Homebrew/brew’s latest GitHub release. To specify an alternate install user, like in situations where the package is installed at the login window before a user has logged in, write a property list file to /var/tmp/.homebrew_pkg_user.plist
with the value HOMEBREW_PKG_USER
. For example, defaults write /var/tmp/.homebrew_pkg_user HOMEBREW_PKG_USER penny
. The file and user must exist prior to install.
xcode-select --install
or
https://developer.apple.com/download/all/) or
Xcode 3bash
) 4The Homebrew installer offers various advanced configuration settings. Most users can skip this section and instead follow the instructions on the homepage!
If you have issues connecting to GitHub.com, you can use Git mirrors for Homebrew’s installation and brew update
by setting HOMEBREW_BREW_GIT_REMOTE
and/or HOMEBREW_CORE_GIT_REMOTE
in your shell environment with this script:
export HOMEBREW_BREW_GIT_REMOTE="..." # put your Git mirror of Homebrew/brew here
export HOMEBREW_CORE_GIT_REMOTE="..." # put your Git mirror of Homebrew/homebrew-core here
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
The default Git remote will be used if the corresponding environment variable is unset and works best for most users.
Note: if you set these variables you are granting these repositories the same level of trust you currently grant to Homebrew itself. You should be extremely confident that these repositories will not be compromised.
You can instruct Homebrew to return to pre-4.0.0 behaviour by cloning the Homebrew/homebrew-core tap during installation by setting the HOMEBREW_NO_INSTALL_FROM_API
environment variable with the following:
export HOMEBREW_NO_INSTALL_FROM_API=1
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
This will make Homebrew install formulae and casks from the homebrew/core
and homebrew/cask
taps using local checkouts of these repositories instead of Homebrew’s API. Unless you are a Homebrew maintainer or contributor, you should probably not globally enable this setting. It can easily be enabled later after installation should it be necessary.
If you want a non-interactive run of the Homebrew installer that doesn’t prompt for passwords (e.g. in automation scripts), prepend NONINTERACTIVE=1
to the installation command.
Check out the Homebrew on Linux installation documentation.
Technically, you can just extract (or git clone
) Homebrew wherever you want. However, you shouldn’t install outside the default, supported, best prefix. Many things will need to be built from source outside the default prefix. Building from source is slow, energy-inefficient, buggy and unsupported. The main reason Homebrew just works is because we use bottles (binary packages) and most of these require using the default prefix. If you decide to use another prefix: don’t open any issues, even if you think they are unrelated to your prefix choice. They will be closed without response.
TL;DR: pick another prefix at your peril!
mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip-components 1 -C homebrew
or:
git clone https://github.com/Homebrew/brew homebrew
then:
eval "$(homebrew/bin/brew shellenv)"
brew update --force --quiet
chmod -R go-w "$(brew --prefix)/share/zsh"
Make sure you avoid installing into:
/tmp
subdirectories because Homebrew gets upset./sw
and /opt/local
because build scripts get confused when Homebrew is there instead of Fink or MacPorts, respectively.Create a Homebrew installation wherever you extract the tarball. Whichever brew
command is called is where the packages will be installed. You can use this as you see fit, e.g. to have a system set of libs in the default prefix and tweaked formulae for development in ~/homebrew
.
Uninstallation is documented in the FAQ.
1 For 32-bit or PPC support see Tigerbrew.
2 macOS 13 (Ventura) or higher is best and supported, 10.11 (El Capitan) – 12 (Monterey) are unsupported but may work and 10.10 (Yosemite) and older will not run Homebrew at all. For 10.4 (Tiger) – 10.6 (Snow Leopard) see Tigerbrew.
3 You may need to install Xcode, the CLT, or both depending on the formula, to install a bottle (binary package) which is the only supported configuration. Downloading Xcode may require an Apple Developer account on older versions of Mac OS X. Sign up for free at Apple’s website.
4 The one-liner installation method found on brew.sh uses the Bourne-again shell at /bin/bash
. Notably, zsh
, fish
, tcsh
and csh
will not work.