Homebrew is an essential tool for macOS developers and power users. It makes it easier to install command-line utilities, libraries, compilers, and other development tools.
Homebrew allows users to easily install apps and tools that would otherwise require manual compilation and configuration. Homebrew also makes it simple to manage, update and uninstall applications, as well as keep track of installed packages.
In this short article, we will show you a few possible solutions to try if you’re encountering “brew: command not found” error message. Also, check out our previous article on the same error for non-Apple-Sillicon Macs.
Add Homebrew path to zprofile
During brew
installation, you are asked to manually add the directory containing the brew
executable to your PATH
environment variable in the final steps. The prompt may look like this:
- Add Homebrew to your PATH in ~/.zprofile:
echo 'eval "$(/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/bin/brew shellenv)"
Code language: PHP (php)
Many users forgot to run these two commands, thinking that they have Homebrew installed properly.
The fix to “brew: command not found” is very simple, just execute those two commands inside the current terminal and brew
should be ready to use right away.
echo 'eval "$(/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/bin/brew shellenv)"
Code language: PHP (php)
The first command adds a line to your profile so that brew
is added to your path in the future.
The second command adds brew to your path so that it can be used in the current session without restarting the system.

Add Homebrew to zshrc
If adding brew
to zprofile
wasn’t enough to bring it back, you may have to try adding it to zshrc
.
~/.zprofile
is one of the zsh startup and shutdown files. It is read at login. ~/.zshrc
is its cousin, which is read when interactive.
Many users reported that adding the following line to their ~/.zshrc
solved the “brew: command not found” problem:
eval $(/opt/homebrew/bin/brew shellenv)
Code language: JavaScript (javascript)
You may have to re-open your Terminal window for changes to take effect.
Note: For Intel Macs, you should use /usr/local
instead of /opt/homebrew
. If you are running bash
, use .bashrc
instead of .zprofile
. Similarly, for those using fish
, add the above line to .config/fish/config.fish
.
Check your PATH environment variable
“Command not found” errors usually means that the brew
binary isn’t in one of the directories specified by your PATH
environment variable (it should be in there).
Most operating systems search for executables and binaries in a specific location. The list of all those locations is saved in an environment variable known as PATH
.
- Run
echo $PATH
on your macOS to see what your current PATH value is. Brew installs to/usr/local/bin
by default. If you don’t see this location, you would have to add it back toPATH
. - Add the line
export PATH="/usr/local/bin:$PATH"
to your~/.bashrc
configuration file. - On Apple Silicon machines (such as the Mac M1),
brew
default installation path is/opt/homebrew/bin
. So on Mac M1, you should addexport PATH="/opt/homebrew/bin:$PATH"
to your~/.bashrc
to fix “brew: command not found”. - If you’re still unsure where is Homebrew, you can check where the
brew
executable file is located by running eitherwhich brew
ortype brew
. - The output of
which brew
ortype brew
should point to/usr/local/bin/brew
path, the/usr/local/bin
is what should be included inPATH
variable.
We hope that the information above is useful and helped you successfully fix the “brew: command not found” error.
If you’re also seeing a “command not found” error message, you may want to check out our other guides to fix pip: command not found, time: command not found and nodemon: command not found.
If you have any questions, then please feel free to ask in the comments below.