Skip to content

How to fix Zsh: Command not found: Brew?

  • by
  • 2 min read

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.

Also read: How to fix error: could not find or load main class org.gradle.wrapper.GradleWrapperMain?


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.

Reinstall Brew

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.

Top 7 IDEs and Text Editors to code Python, Java, C++, HTML and more

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:

export PATH=$PATH:/opt/homebrew/bin

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

>