Updated Aug 11, 2024, 2:00 PM EDT
Raghav Sethi began his tech writing journey in 2022, contributing to his college’s open-source community blog. Later that year, he joined MakeUseOf, and since then has written extensively about Apple, Android, and AI. His work ranges from hands-on experiments to opinion pieces that explore the bigger picture behind emerging tech trends.
Alongside his work at MUO, you can also find Raghav’s articles at XDA Developers, where he mainly focuses on Linux and the world of open-source software.
Outside of writing, Raghav enjoys working on coding projects, playing the guitar, and living life on the edge by installing the latest beta software on his daily devices.
Sign in to your MakeUseOf account
Jump Links
-
1. Try Reinstalling Homebrew
-
2. Add Brew to the PATH Environment Variable
-
3. Install Xcode Command Line Tools
If you see the "zsh: command not found: brew" error while using Homebrew, it most likely means the Terminal app can't find the Homebrew executable. Don't worry, though, because we'll explore some potential solutions to fix this problem below.
1. Try Reinstalling Homebrew
Reinstalling Homebrew can remove any corrupted or outdated files and install a fresh copy of Homebrew. To remove Homebrew, you can follow these steps:
-
Open Terminal on your Mac and uninstall Homebrew by pasting the following command and hitting the Return key:
brew uninstall --force homebrew -
Type in the following command and hit Return to install Homebrew again:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
This will download and install the latest version of Homebrew. Once you restart the Terminal app, you should be able to use the brew command without any problems.
2. Add Brew to the PATH Environment Variable
There is a good chance that Homebrew could not be added to the PATH variable during installation, meaning your shell is unable to locate the Homebrew executable.
You can fix this by manually adding Homebrew to your PATH via the Terminal. The command varies slightly depending on whether your Mac has an Intel processor or an Apple silicon chip. Just copy and paste the appropriate command for your Mac into the Terminal app.
If you have a Mac with an Apple silicon chip, enter this command:
export PATH="/opt/homebrew/bin:$PATH"
If your Mac has an Intel processor, enter this command instead:
export PATH="/usr/local/bin:$PATH"
You can check if Homebrew was successfully added to the PATH variable using the following command:
echo $PATH
This will display all the executable binaries that Terminal can find. If Homebrew is present in the list, it means that Terminal is successfully able to locate the Homebrew executable.
Xcode Command Line Tools is a package developed and maintained by Apple that contains all the debuggers, compilers, and tools included with the entire Xcode IDE. Several users have reported that Homebrew cannot work without Xcode Command Line Tools installed. You can install it by typing the following command into Terminal and hitting Return:
xcode-select --install
After this, you can verify the installation using the following command:
xcode-select -p
If the installation was successful, you should get the following output after entering the command:
/Library/Developer/CommandLineTools
Homebrew offers several useful apps and is a must-have utility for every Mac power user. If you're encountering the "zsh: command not found: brew" error, one of the troubleshooting steps we discussed above should resolve the problem and allow you to enjoy the best package manager available for macOS.