Typing brew install and getting "zsh: command not found: brew"? Homebrew is almost certainly installed - your shell just does not know where to find it. Here is the fix.
The Error
$ brew install wget
zsh: command not found: brew
On a Mac still running bash, the same problem prints:
bash: brew: command not found
Quick Fix (Apple Silicon)
Run these three lines in Terminal:
echo >> ~/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
Then:
brew --version
On an Intel Mac, substitute the path:
echo 'eval "$(/usr/local/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/usr/local/bin/brew shellenv)"
Why This Happens
When you type brew, zsh walks each directory in your PATH environment variable looking for an executable of that name. If it finds none, it reports command not found. That message says nothing about whether Homebrew exists on disk - only that it is not somewhere the shell was told to look.
On Apple Silicon Macs, Homebrew installs to /opt/homebrew. That directory is not on the default macOS PATH. The installer knows this, and at the end of a successful install it prints a "Next steps" section containing exactly the two lines above - but it deliberately does not edit your shell profile for you. Anyone who closes the terminal without reading that output ends up here.
On Intel Macs, Homebrew installs to /usr/local, and /usr/local/bin has been on the default PATH forever. That is why this error is overwhelmingly an Apple Silicon experience.
The split exists so that an Intel Homebrew running under Rosetta and a native ARM Homebrew can sit on the same machine without overwriting each other.
Step 1: Is Homebrew Actually Installed?
Do not guess. Check both locations:
ls /opt/homebrew/bin/brew # Apple Silicon
ls /usr/local/bin/brew # Intel
- One of them lists the file - Homebrew is installed. This is a PATH problem; continue to step 2.
- Both say "No such file or directory" - Homebrew is not installed. Skip to step 4.
Step 2: Add Homebrew to Your PATH
The recommended approach is brew shellenv rather than a hardcoded export PATH= line. shellenv emits the full set of variables Homebrew expects - PATH, MANPATH, INFOPATH and several HOMEBREW_ values - and picks the right prefix automatically, so the same line works on either architecture.
Append it to your profile and apply it to the current session:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
The second line matters. A shell reads its profile only when it starts, so without it you would have to open a new window before anything changed.
Inspect the result if you want to see what it did:
/opt/homebrew/bin/brew shellenv
Step 3: Check You Edited the Right File
Two things commonly go wrong here.
Wrong shell. Confirm what you are running:
echo $SHELL
/bin/zsh means ~/.zprofile is correct. /bin/bash means you want ~/.bash_profile instead. macOS has defaulted to zsh since Catalina, but an account created on an older system and carried forward through migrations can still be on bash.
Wrong profile file. zsh reads different files depending on how it was started:
| File | Read by |
|---|---|
~/.zprofile | Login shells - what Terminal.app and iTerm2 open by default |
~/.zshrc | Interactive shells - including many editor and IDE terminals |
~/.zshenv | Every zsh invocation, including scripts |
Homebrew recommends ~/.zprofile, and for Terminal.app that is sufficient. If brew works in Terminal but a tool such as an IDE's integrated terminal still cannot find it, that tool is spawning a non-login shell - add the same line to ~/.zshrc as well. Putting it in ~/.zshenv is not recommended, because it then runs for every script invocation too.
Step 4: Install Homebrew If It Is Missing
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
You will be prompted for your password, because the installer needs sudo to create its directories. Read the "Next steps" output at the end - it prints the exact PATH commands for your machine. Running those is what prevents you landing back on this error.
Step 5: Rule Out Rosetta
If Homebrew is at /opt/homebrew but your shell keeps behaving as though it should be at /usr/local, your terminal may be running translated:
uname -m
arm64- running natively, as expected on Apple Siliconx86_64on an M-series Mac - your terminal is running under Rosetta
To change it: quit the terminal app, find it in Applications, press Cmd+I, and untick "Open using Rosetta." Reopen it. Unless you are deliberately maintaining an Intel toolchain, native is what you want.
Verify the Fix
# Version
brew --version
# Which binary answered
which brew
# Broader health check
brew doctor
Expected output:
Homebrew 4.4.0
/opt/homebrew/bin/brew
Your system is ready to brew.
If which brew returns nothing while /opt/homebrew/bin/brew --version works, the PATH line has not been applied to this shell - open a new window.
Prevention
- Read the installer's "Next steps" output. It is not decoration; it contains the commands that finish the install.
- Prefer
eval "$(brew shellenv)"over a hardcodedexport PATH=/opt/homebrew/bin:$PATH. The shellenv form keeps working if you move between Intel and Apple Silicon machines or if Homebrew changes its prefix. - Add the line once, to
~/.zprofile, rather than pasting it repeatedly - duplicated entries make PATH harder to reason about later. - After any migration to a new Mac, re-run the shellenv step. Migration Assistant copies your profile but not the Homebrew installation itself, which produces this error on a machine where it previously worked.
Summary
- Check:
ls /opt/homebrew/bin/brew(Apple Silicon) orls /usr/local/bin/brew(Intel) - Installed but not found: append
eval "$(/opt/homebrew/bin/brew shellenv)"to~/.zprofile, then run the same line - Not installed: run the install script from brew.sh and follow its "Next steps"
- Still failing: check
echo $SHELLanduname -m - Verify:
brew --versionandbrew doctor