zsh

How to Fix zsh: command not found: brew on Mac

Homebrew, commonly known as brew, is a free and open-source package manager used to install, manage, and update software on macOS. It is a powerful command-line tool that makes it easy for you to install software with a single command. It has an easy and effective solution for Mac users since the packages installed from Homebrew are reliable, up-to-date, and compatible with your system.

However, while using the brew command, the user may encounter the error zsh: command not found: brew. The occurrence of this error will prevent users to execute brew-related commands.

Read this guide for a quick solution to fix the zsh: command not found: brew error on Mac.

How to Fix zsh: command not found: brew on Mac

When you try to brew-related command on your Zsh terminal, you will encounter the following error:

The main cause of this error to occur in Zsh is because of missing Homebrew installation on your Mac system. By default, Homebrew is not preinstalled on your Mac system and you have to manually install it to use it for installing applications on your system.

Install Homebrew on Mac

The most straightforward way to install Homebrew on Mac is to use the following installation script created by the Homebrew developer.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

The above script needs to be run on the terminal to initiate the Homebrew installation on Mac. You may need to enter the user’s password for sudo access.

Then press Enter when asked to begin the Homebrew installation on Mac.

Once the Homebrew installation is completed, ensure the successful installation by running the following command:

brew --version

This ensures that you have successfully installed Homebrew on Mac and you are good to execute brew-related commands without getting any errors.

Conclusion

Getting the zsh: command not found: brew error on Mac is frustrating because it hinders you from using brew-related commands. You can fix this issue by installing Homebrew on your Mac terminal by executing the official installation script of Homebrew. After the installation, you can test the brew commands to ensure it is working on your system.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.