All UNIX-based operating systems have their package managers of choice. As far as macOS is concerned, that package manager is Homebrew. That said, while package managers do make it extremely easy to install and manage different utilities on your PC, they can also sometimes run into issues.
In this article, we’re talking about the “Zsh: command not found: Brew” error, its causes and what you can do to solve the problem.
What causes the issue?
Based on the error message, the most obvious cause of the problem is that either Brew isn’t installed or the current installation is corrupt or otherwise broken. Additionally, other common reasons include:
- Brew is missing from the PATH variable.
- The download package was corrupt or damaged.
How to fix this issue?
Here are x fixes you can try out.
One of the first things you should do is reinstall Brew. To do so, simply run the command given below to overwrite the existing installation.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
This should get Brew up and running.
Add Brew to the PATH variable
Another reason why you might see the aforementioned error even after Brew is installed is that the tool hasn’t been added to the PATH variable which allows the terminal to identify the command, Brew.
All you have to do is head over to /opt/homebrew/bin/ — the directory where Brew is installed and run the following command in the terminal:
This will copy the Brew binary’s path to the PATH variable, hence making it executable by running the command from anywhere in the terminal.
Also read: World War 3 error code40302: 6 Fixes