zsh: command not found: brew on Mac: check the prefix, then fix PATH
Frank Zhang
- 4 minutes read - 1684 wordsTL;DR
This error means the current shell has no brew on PATH. Often the installer already placed the binary in the default prefix, and the post-install PATH step was skipped. General guidance, not a first-hand session.
Check whether the brew binary exists in the default prefix, then add Homebrew to PATH the way the official install docs describe. Do not run sudo brew, and do not uninstall and reinstall first. This page is general guidance, not a record of one session. The commands were not re-run on a Mac for this page. There is no first-hand screenshot of the error. The sources are the Homebrew docs as read on 2026-11-30. If man brew, the installer’s Next steps, or the text on your screen disagrees with this page, trust that copy.
This is the line people paste, often right after the install script finishes, after opening a new Terminal window, or the first time they use Terminal on an Apple Silicon Mac:
zsh: command not found: brew
In bash it is usually bash: brew: command not found. Either way, the current shell cannot find an executable named brew on PATH. That is not proof the installer failed, and it is not proof Homebrew was deleted. The Homebrew Installation page, as read on 2026-11-30, is blunt: the installer prints directions for updating your shell’s config; if you don’t follow those directions, Homebrew will not work.
Which errors this page covers
This page is for zsh: command not found: brew and brew command not found, including the “after install” and Mac / M1 / M2 / M4 / M5 variants. On 2026-11-30, en-US Google autocomplete returned 10 suggestions for both zsh command not found brew and brew command not found mac, and the second list included brew command not found mac after install plus the M1 / M4 / M5 variants. Bing had the Mac and “after install” wording too. zh-CN Google returned the same English roots with “how to fix” wording.
It is not for:
command not foundfornpmor a global CLI that works in your terminal but fails in an AI agent, a script, or a non-interactive shell. That is a Node prefix / interactive-versus-non-interactive mismatch; see command not found after npm install -g: your terminal and the AI agent are using different Node installs.python: command not found. That is thepythonversuspython3issue on macOS, not a missing Homebrew prefix onPATH.xcrun: invalid active developer pathafter a macOS update. That is the developer tools path; see xcrun: invalid active developer path after a macOS update. Missing Command Line Tools can matter when a formula is built from source. It is not thisbrewlookup failure.- Slow
brew updatedownloads, or mirror configuration. Those are network problems. This error happens before the shell has foundbrew, so a mirror is not the first step.
Read-only: a file on disk is not the same as a command on PATH
The FAQ entry on the default location, as read on 2026-11-30, lists the default prefixes:
- macOS on Apple Silicon:
/opt/homebrew - macOS on Intel:
/usr/local(the docs call this legacy, Tier 3 support) - Linux:
/home/linuxbrew/.linuxbrew
The brew.sh homepage, read the same day, lists the same three. This page is about a missing brew command on a Mac; the Linux prefix is here only for comparison.
In Terminal, check whether the file exists (a missing file makes ls error; that is an expected read-only result):
ls -l /opt/homebrew/bin/brew
ls -l /usr/local/bin/brew
Then see what this shell already knows, what PATH contains, and which architecture the process is:
command -v brew
echo "$PATH"
arch
No output from command -v brew only means this shell cannot see it. Do not treat that as proof the file is gone. Common Issues: Multiple Homebrew installations also notes that Migration Assistant, or an x86_64 terminal on Apple Silicon, can leave both /usr/local and /opt/homebrew active. It suggests:
arch
command -v brew
brew --prefix
and says an Apple Silicon shell should normally report arm64 and use /opt/homebrew. If command -v brew is already empty, brew --prefix will repeat command not found. That is consistent. Use the full path you actually saw with ls, such as /opt/homebrew/bin/brew --prefix or /usr/local/bin/brew --prefix. Do not run the official uninstall against both prefixes.
Two common branches, judged from your screen:
- The file is there, but it is not on
PATH.lsshows/opt/homebrew/bin/brew, yetcommand -v brewis empty, orecho "$PATH"does not include/opt/homebrew/bin(on Intel,/usr/local/bin). This is the skipped post-install step. FixPATHnext. Do not reinstall. - Neither default path has the file. Homebrew is not installed, or it was installed to a custom prefix. Do not invent a
PATHentry for a binary that is not there. Use the official installer, then still do theshellenvstep.
If the file is there: add the prefix to PATH the official way
Post-installation steps tells you to update your shell config with this line, replacing the placeholder with the Homebrew prefix on this machine:
eval "$(<Homebrew prefix path>/bin/brew shellenv)"
On Apple Silicon, the default form is:
eval "$(/opt/homebrew/bin/brew shellenv)"
On Intel, the default prefix is /usr/local, so the path is /usr/local/bin/brew. Call brew by full path here, because it often is not on PATH yet. The brew manpage for shellenv, read on 2026-11-30, says evaluating its output adds that installation to PATH, MANPATH, and INFOPATH, and exports HOMEBREW_PREFIX and related variables. It suggests putting that evaluation in your dotfiles. The macOS examples are ~/.bash_profile or ~/.zprofile; on Linux, ~/.bashrc or ~/.zshrc. The Installation page itself uses ~/.bashrc or ~/.zshrc as examples. Follow the Next steps the installer printed. Do not leave two conflicting copies in different files.
Editing the file only affects shells you start later. In the current window, run the same eval once more, or open a new Terminal window, then check:
command -v brew
brew --prefix
command -v brew should point at the file you already listed, and brew --prefix should be the matching /opt/homebrew or /usr/local. If a new window works and the old one still fails, the old session has not loaded the new config. That is not a second failed install.
If you share one set of dotfiles across macOS and Linux, Tips and Tricks shows this detection snippet:
command -v brew || export PATH="/opt/homebrew/bin:/home/linuxbrew/.linuxbrew/bin:/usr/local/bin"
command -v brew && eval "$(brew shellenv)"
The same page says you may need to adapt it for your shell and environment. It is not the first step for most people; the installer’s printed commands are.
If brew is missing from the default paths: install the official way
Only install once you have confirmed that neither default path has brew, or you know you never installed it. The official command on brew.sh is:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Installation footnote 4 says this one-liner uses /bin/bash; zsh, fish, tcsh, and csh will not work for it. The script explains what it will do and pauses for confirmation. macOS also has an official .pkg installer, documented on the homepage and the Installation page; it supports Apple Silicon only and installs to /opt/homebrew.
After the install finishes, you still need the shellenv step above. “Installation successful!” without the Next steps is how this command not found comes back.
Do not download a “Homebrew installer” from an untrusted site, and do not change to a custom prefix just to clear this error. The official docs tie the default prefix to bottles (pre-built packages). Custom prefixes have extra constraints; this page does not walk through moving an install.
For OS support, trust the Installation footnotes as of 2026-11-30 rather than this page: on Apple Silicon, macOS 15 (Sequoia) through 27 (Golden Gate) is documented as best and supported; macOS 11–14 is unsupported but may work; every Intel Mac configuration that can run Homebrew is Tier 3; macOS 10.15 (Catalina) and older will not run Homebrew at all. This page does not tell you whether to upgrade.
What not to do first
- Do not run
sudo brew. The FAQ on sudo says running anybrewcommand withsudotrusts the prefix owner to run arbitrary code as root.command not foundis not a permissions error;sudodoes not put a missing command onPATH. - Do not uninstall and reinstall before you have looked at
ls. If the file is already in the default prefix, the gap isPATH, not the install. - Do not turn off SIP, disable the firewall, or change Full Disk Access for this sentence. Those are different problems.
- Do not treat
alias brew=...or a one-offPATH=tweak as the lasting fix. The documented persistent form iseval "$(…/bin/brew shellenv)".
Where this page stops
This page only covers a Mac shell that cannot find the brew executable. It does not choose formulae or set up mirrors, and it does not claim that fixing PATH in your login shell will make brew visible to a non-interactive job, CI, or an AI agent. That mismatch is closer to command not found after npm install -g, with Homebrew as the tool instead of a Node CLI. Trust the commands, prefixes, and config file names on your screen. If ls shows a path that is neither /opt/homebrew nor /usr/local, read the installer output or brew --prefix before editing your config; do not copy someone else’s username or prefix.
Other paths on the site start at Start Here. The Chinese writeup is zsh: command not found: brew:先确认二进制在不在,再补上 PATH.
If this post helps, you can sponsor the blog. This is voluntary personal support, not a charitable donation.