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
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:
Code language: PHP (php)
- Add Homebrew to your PATH in ~/.zprofile: echo 'eval "$(/bin/brew shellenv)"' >> ~/.zprofile eval "$(/bin/brew shellenv)"
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.
Code language: PHP (php)
echo 'eval "$(/bin/brew shellenv)"' >> ~/.zprofile eval "$(/bin/brew shellenv)"
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
zprofile wasn’t enough to bring it back, you may have to try adding it to
~/.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)
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
.bashrc instead of
.zprofile. Similarly, for those using
fish, add the above line to
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
echo $PATHon your macOS to see what your current PATH value is. Brew installs to
/usr/local/binby default. If you don’t see this location, you would have to add it back to
- Add the line
export PATH="/usr/local/bin:$PATH"to your
- On Apple Silicon machines (such as the Mac M1),
brewdefault installation path is
/opt/homebrew/bin. So on Mac M1, you should add
export PATH="/opt/homebrew/bin:$PATH"to your
~/.bashrcto fix “brew: command not found”.
- If you’re still unsure where is Homebrew, you can check where the
brewexecutable file is located by running either
- The output of
type brewshould point to
/usr/local/binis what should be included in
We hope that the information above is useful and helped you successfully fix the “brew: command not found” error.
If you have any questions, then please feel free to ask in the comments below.