Zsh: command not found: brew
How to fix zsh: command not found: brew. When Homebrew is not installed or the Zsh shell $PATH is not set correctly.
The zsh: command not found: brew error occurs when Homebrew is not installed, or the $PATH is missing or incorrect, preventing the shell from finding the brew command, which is the command for Homebrew, the popular macOS package manager.
Many people take the error to mean Homebrew is not installed, and install it again. Usually Homebrew is installed, and the shell just doesn't know where to look for it. Once you know how the shell finds commands, you can fix this error yourself, and use the same method whenever the shell can't find a command you installed.
Here are likely reasons for this error:
- You installed Homebrew in the terminal window you are using. Open a new window.
- A
$PATHline in a shell configuration file is missing, out of date or broken, after an older install, an uninstall, or settings copied from another Mac. - Homebrew is not installed, or the install stopped before it finished, as it does on an Intel Mac.
- You are running
brewfrom an app or from a terminal built into another tool, which doesn't see Homebrew's folder.
Fixing this error is one step in setting up your Mac. See the full roadmap to set up a Mac.
Before you get started, try our free app
I recommend using our free app to get Homebrew working on your Mac. It is a FREE Mac app that installs Homebrew, configures Homebrew, and verifies it is working. It does everything this guide covers, but easier and faster. Here are all the details about the app before you download. Then:
Intel Macs
Homebrew can't be installed on Intel-based Macs (as of September 2026). On an Intel Mac, use MacPorts instead. If you ran the install script recently on an Intel Mac, it displayed Homebrew on macOS is only supported on Apple Silicon processors! and installed nothing, which is why brew is not found. An Intel Mac that installed Homebrew before September 2026 is unaffected, and the $PATH advice below still applies to it.
The brew command not found error
This is the error you'll see:
$ brew ...
zsh: command not found: brew
How to Fix the Error - Step by Step
Here are steps to fix "zsh: command not found: brew":
- Open a new terminal window.
- Check if Homebrew is installed.
- Check if the
$PATHsetting is missing or incorrect. - Fix a configuration file line that runs a missing
brew. - If the error appears only in an app or another tool's terminal, set the
$PATHfor that app.
These instructions are for a terminal running Zsh, the Z shell, on a newer Mac. See Shell Configuration for changing the shell if you are using an older macOS version with the Bash shell.
See my video on fixing zsh: command not found: brew.
Why you see 'zsh: command not found: brew'
You are trying to run Homebrew in a terminal application. Homebrew is used for installing command line software. The terminal interprets commands using the Zsh shell. The error messages shows that the Zsh shell cannot find Homebrew's brew command.
Here is what likely went wrong:
- Most likely, if you just installed Homebrew, you are still in the terminal window where you installed it. Since June 2025, Homebrew's install script adds Homebrew to the
$PATHby itself, but only re-opened terminal windows see the change. - Homebrew is installed, but the
$PATHdoesn't include its folder. That happens with installs from before June 2025 (for those versions, the install script expected you to set the$PATH, in a~/.zprofileor~/.zshrcconfiguration file). You might also see the error with installs made without an administrator password, or when a configuration file has changed the$PATH. Without a correct$PATH, the shell cannot find thebrewcommand. - A configuration file might still run Homebrew from a folder where it no longer exists, after you uninstalled Homebrew or copied the file from another Mac. You'll see a
no such file or directorymessage when a terminal window opens. - You may be following instructions that assume you have installed Homebrew previously but you didn't, or Homebrew is now missing.
- You are typing
brewin an app, or in a terminal built into another tool, that started without Homebrew's folder in its$PATH. Terminal, iTerm2 and Warp see Homebrew's folder; some other apps and tools don't.
Here are the steps to take to fix the error.
Open a new terminal window
If you just installed Homebrew, this is usually the fix. Since June 2025, Homebrew's install script writes a one-line file, /etc/paths.d/homebrew, containing /opt/homebrew/bin. When a terminal window opens, its shell runs a macOS program, path_helper, that reads the files in /etc/paths.d and adds their folders to the $PATH. A window that was already open when you installed Homebrew started with the old $PATH, so it can't find brew.
Open a new terminal window (press Command-N), or quit the terminal application and launch it again. If you prefer to keep using the same window, run the last command from the install script's "Next steps", which sets the $PATH for this window only:
$ eval "$(/opt/homebrew/bin/brew shellenv zsh)"
Then try:
$ brew doctor
You should see Your system is ready to brew. If so, Homebrew is installed and the $PATH is set correctly. The shell session you were using started before the $PATH changed.
If you still see zsh: command not found: brew, check whether Homebrew is installed.
Is Homebrew installed?
Let's check if Homebrew is available but the $PATH is not set. It's also possible that Homebrew is not installed.
You can try running the command with its full path to find out if Homebrew is installed. On a Mac with Apple Silicon, Homebrew is installed by default in the /opt/homebrew/bin folder. We'll try entering the brew command with its full file path.
$ /opt/homebrew/bin/brew doctor
Your system is ready to brew.
You are trying brew doctor with the full path to the brew executable file to check if it runs.
Have you got an older Intel Mac with Homebrew installed before September 2026? Homebrew put itself into the /usr/local/bin directory, which is configured by macOS default with the correct $PATH environment variable. Try /usr/local/bin/brew doctor to find out if "Your system is ready to brew" on that Mac.
For both newer and older Macs, if you see Your system is ready to brew when you provide the full path, Homebrew is available but the $PATH is not set correctly. See the next section to check the $PATH setting.
In the unusual case that you see zsh: command not found: brew, with a correct $PATH setting and Homebrew files in /opt/homebrew/bin, or in /usr/local/bin on an older Intel Mac, you can try reinstalling Homebrew. Uninstall Homebrew and then go to Install Homebrew.
Check the $PATH
If you provide the full path to the Mac brew executable file and see Your system is ready to brew but you don't see it unless you provide the full path, check the $PATH setting. Try:
$ echo $PATH
...
The $PATH should contain /opt/homebrew/bin, or /usr/local/bin on an older Intel Mac. It should be among the highest priority directories, in a left-most position.
If /opt/homebrew/bin appears only at the end, after /usr/bin, it came from Homebrew's install script. The brew command works. However, when you install a command with Homebrew that macOS also has, such as git, the shell finds Apple's copy in /usr/bin first, and brew doctor then warns /usr/bin occurs before /opt/homebrew/bin in your PATH (see Homebrew doctor). The brew shellenv line below puts Homebrew's folder first.
If /opt/homebrew/bin appears twice, at the start and at the end, both the install script's setting and the brew shellenv line are working. That is harmless.
Setting the $PATH for a Mac with Apple Silicon
On a Mac with Apple Silicon, Homebrew requires a $PATH setting, because Homebrew's folder, /opt/homebrew/bin, is not in the default $PATH on macOS. Since June 2025, Homebrew's install script adds it for you, at the end of the $PATH. Homebrew still recommends a line in your ~/.zprofile file that puts its folder first, and the install script shows that line in its "Next steps". Homebrew's own installation page still says Homebrew "will not work" without that line, and doesn't mention the file the install script writes. Today the line isn't needed to find brew in a new window. It is needed so the commands you install with Homebrew run instead of Apple's older copies.
The $PATH environment variable determines the directories the shell searches for executable files. The $PATH is typically set in the ~/.zprofile file. See the guide Mac PATH for instructions. The article .zshrc or .zprofile explains which configuration file to use.
There are two ways to set the $PATH for Homebrew on a Mac with Apple Silicon.
Use brew shellenv to set $PATH
Homebrew provides instructions to use a supplied shell script to set the $PATH variable. In the ~/.zprofile file or ~/.zshrc file, you should see this:
eval "$(/opt/homebrew/bin/brew shellenv zsh)"
You may see the same line without zsh at the end, as older installs wrote it. Both work.
From the command line, try running shellenv and check the response:
$ /opt/homebrew/bin/brew shellenv
export HOMEBREW_PREFIX="/opt/homebrew";
export HOMEBREW_CELLAR="/opt/homebrew/Cellar";
export HOMEBREW_REPOSITORY="/opt/homebrew";
fpath[1,0]="/opt/homebrew/share/zsh/site-functions";
export FPATH;
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin${PATH+:$PATH}";
[ -z "${MANPATH-}" ] || { export MANPATH="${MANPATH%"${MANPATH##*[!:]}"}"; export MANPATH=":${MANPATH#"${MANPATH%%[!:]*}"}"; };
export INFOPATH="/opt/homebrew/share/info:${INFOPATH:-}";
If you don't see a similar response, it's likely that Homebrew is not installed. See the guide to Install Homebrew.
Set $PATH directly
Not everyone follows the official Homebrew instructions to run shellenv from a configuration file. You may have edited a configuration file to set the $PATH directly.
These are the two zsh shell initialization files that are commonly used to set environment variables. $PATH is typically set in either:
~/.zshrc(Zsh Run Control): This file is the primary configuration file for user-specific shell customizations, such as setting command aliases and adjusting the shell prompt.~/.zprofile(Zsh Profile): This file is read only on login. It's ideal for commands that should be executed only once when a terminal window is opened, such as setting the$PATHenvironment variable.
The tilde ~/ means the ~/.zshrc or ~/.zprofile file is found in your user home directory. If you are a user on a new Mac, you won't find these files. See the guide Shell Configuration for instructions about how to create, find and open the shell configuration files.
Check the ~/.zprofile file or ~/.zshrc file and you might see something like this:
eval "$(/opt/homebrew/bin/brew shellenv)"
or
export PATH=/opt/homebrew/bin:/opt/homebrew/sbin:$PATH
Also look for a line that sets the $PATH to a fixed list of folders, without $PATH in it, such as export PATH=/usr/local/bin:/usr/bin:/bin. That line replaces the $PATH that macOS and Homebrew's install script set up, so if Homebrew's folder isn't in the list, the shell can't find brew. Add /opt/homebrew/bin to the list, or add the brew shellenv line after it, in the same file.
It's best to set the $PATH variable with Homebrew's recommended shellenv. See the guide Install Homebrew for instructions.
Fix .zprofile: no such file or directory: /opt/homebrew/bin/brew
If you uninstalled Homebrew, or copied your shell configuration files from another Mac, you may see a message like this at the top of every new terminal window:
/Users/yourname/.zprofile:2: no such file or directory: /opt/homebrew/bin/brew
The message names the file and the line number. Line 2 of ~/.zprofile runs brew shellenv, but there is no brew at /opt/homebrew/bin/brew, so the line fails every time a window opens, and brew is not found. The same kind of message can name a different file, such as a script your old Mac had and this one doesn't.
There are two fixes:
- If you want Homebrew, install Homebrew. The line works again once
brewis in place. - If you don't want Homebrew, remove the line.
To edit the file in TextEdit, run:
$ open -e ~/.zprofile
Delete the line the message names, save the file, and open a new terminal window. If the message names ~/.zshrc, open that file instead. You can also see these files in the Finder, where they are hidden: open your home folder and press Command-Shift-Period to show hidden files. Uninstall Homebrew explains which other lines and files an uninstall leaves behind.
If every command, even ls, gives command not found, a line in a configuration file has set the $PATH to nothing, or to a short list. Look for a line that starts with export PATH= and has no $PATH in it, and fix or remove it as described in the previous section.
In an app or another tool's terminal
Terminal, iTerm2 and Warp start a login shell, which reads /etc/paths.d and your ~/.zprofile file, so brew is found. Other apps may not. An app started from the Dock or the Finder gets a short default $PATH, /usr/bin:/bin:/usr/sbin:/sbin, without Homebrew's folder. A terminal built into another tool, such as a code editor or an AI coding tool, may start a shell that isn't a login shell and skips those files. Then brew, and every command you installed with Homebrew, is not found in that app, though it works in Terminal.
The fix belongs to the app or tool. Look in its settings or documentation for an option to start a login shell or to set the $PATH. Homebrew's FAQ gives a command that adds Homebrew's folder to the $PATH of every app you start from the Dock or the Finder, for all users of the Mac, after a restart:
$ sudo launchctl config user path "$(brew --prefix)/bin:${PATH}"
Run it in Terminal, where brew is found, and restart your Mac.
Resources
If you are starting with programming on the Mac, see Mac Terminal for basic concepts and How to Open Terminal in Mac. Also see the guide Shell Configuration. The article .zshrc or .zprofile explains which configuration file to use.
You also can learn more about the Homebrew package manager.
What's next
The Mac Install Guide website contains all the instructions you need to set up your Mac as a development environment for programming. See a list of Best Homebrew Packages and Apps.