Linux Commands

Brew Command Not Found

“Homebrew, or brew for short, is a free and open-source package manager for Mac and Linux operating systems. The brew is a lightweight command-line utility built on top of the Ruby programming language.

It offers an easy-to-manage command-line interface that allows you to download, install, update, and uninstall packages. Brew uses a set of open-source repositories, and developers can add or remove packages.

For this tutorial, we will learn how to resolve the “brew command not found” error you may encounter when you run the brew command.”

What is “brew command not found”?

The “brew command not found” error occurs when your system cannot find the brew binary in its path. Unix systems have a list of directories in which to check for binaries of a command.

Therefore, when you run a command from your terminal, the system will search this list of directories for the binary with that name. If the system does not find a binary with such a name, it will return the “command not found” error.

The list of directories where the system will search is stored in the PATH environment variable.

You can view the list by running the command:

$ echo $PATH

The command should print all the directories where your system will search for the target binaries.

If you have Homebrew installed and still getting the “brew command not found” error, it’s mainly because the path to the brew binary is missing from the path environment variable.

Let us discuss various ways to resolve it.

Install Homebrew

The first step is to ensure that Homebrew is installed correctly on your system. Run the command below to install Homebrew on your system.

/bin/bash -c "$(curl -fsSL"

If you wish to re-install Homebrew, run the command below to uninstall Homebrew:

$ NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL"

You can then run the command above to re-install it.

Adding Brew to Path

By default, the brew will automatically add the install directory to the path upon installation. However, this may sometimes fail and require you to add the directory manually.

You can do this by running the command:


$ echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile

If Homebrew is installed in a different directory, ensure to replace the /usr/local/bin with the target directory.

For example, in macOS, brew is installed in /opt/homebrew/bin.


echo 'export PATH="/usr/local/bin:$PATH"' >> $HOME/.zshrc

Similarly, feel free to replace the /usr/local/bin with the target directory.

Once completed, you can confirm that the brew command is working properly by running the command:

$ brew –version
Homebrew 3.5.1
Homebrew/homebrew-core (git revision 9f9fcb8997c; last commit 2022-06-08)

And there you have it; Homebrew is successfully installed and accessible from your terminal session.


Through this tutorial, you learned the possible causes of the “brew command not found” error and various ways to fix it. We hope this article has helped you.

Thanks for reading!!

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list