How to fix "zsh: command not found: brew" on a Mac

Researched, not yet tested: written from Homebrew's installation docs and install script output; we haven't run it on a Mac yet. Check the commands against your setup.

Your shell doesn’t know where brew is. On an Apple Silicon Mac, Homebrew installs to /opt/homebrew, which isn’t on the default PATH, so add it:

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
brew --version

The first line saves the setting for new Terminal windows. The second applies it to the window you have open. This is the “Next steps” the Homebrew installer prints at the end, and it’s the step most people skip.

Find your cause

Check two things first:

uname -m                     # arm64 = Apple Silicon, x86_64 = Intel
ls /opt/homebrew/bin/brew /usr/local/bin/brew
What you see Cause Fix
arm64, and /opt/homebrew/bin/brew exists Homebrew installed, not on PATH The two lines above
Neither path exists Homebrew isn’t installed Install it (below)
x86_64, and /usr/local/bin/brew exists PATH changed or shell profile broken Check echo $PATH includes /usr/local/bin
arm64, only /usr/local/bin/brew exists An Intel install copied by Migration Assistant Reinstall Homebrew for Apple Silicon
echo $SHELL shows /bin/bash You use bash, not zsh Put the line in ~/.bash_profile instead

Fix: Homebrew isn’t installed

Install it with the command from brew.sh, then run the two “Next steps” lines it prints:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Our Homebrew install guide covers the requirements and the PATH step in more detail.

Fix: an Intel install on an Apple Silicon Mac

If you moved to an Apple Silicon Mac with Migration Assistant, you may have an old Intel Homebrew in /usr/local that runs under Rosetta. Homebrew’s supported setup on Apple Silicon is /opt/homebrew, so install it there with the command above and add the shellenv line. You can remove the Intel copy afterwards with Homebrew’s uninstall script.

Fix: the line is in the wrong file

zsh reads ~/.zprofile for login shells, which is what Terminal opens. If you added the line to ~/.zshrc instead it usually still works, but check you didn’t add it twice or to a file zsh doesn’t read. Open the file with open -e ~/.zprofile to check.

Confirm it worked

Open a new Terminal window and run:

which brew        # /opt/homebrew/bin/brew on Apple Silicon
brew --version
brew doctor

brew doctor should end with “Your system is ready to brew.”

FAQ

Where is brew installed on Apple Silicon?

In /opt/homebrew, so the command is /opt/homebrew/bin/brew. On Intel Macs it's /usr/local/bin/brew. See Homebrew's installation page.

Why does brew work in one terminal window and not another?

You ran the eval line in one window but didn't save it to ~/.zprofile, so new windows don't get it. Add the line to the file as shown on this page.

I use bash, not zsh. What changes?

The error reads -bash: brew: command not found, and the line goes in ~/.bash_profile instead of ~/.zprofile. Run echo $SHELL to see which shell you use.

Should I add /opt/homebrew/bin to PATH by hand?

The brew shellenv line does that and also sets the other variables Homebrew uses, so it's the safer choice.