How to fix Mac Homebrew error 'zsh: command not found: brew'

If you see the error zsh: command not found: brew when using Homebrew, it's likely that the Terminal application couldn't find the Homebrew executable.

 Don't worry, though, as we'll explore some potential solutions to fix this problem below.

1. Try reinstalling Homebrew

How to fix Mac Homebrew error 'zsh: command not found: brew' Picture 1How to fix Mac Homebrew error 'zsh: command not found: brew' Picture 1

Reinstalling Homebrew can delete any corrupt or outdated files and install a new copy of Homebrew. To remove Homebrew, you can follow these steps:

a. Open Terminal on your Mac and uninstall Homebrew by typing the following and pressing the Return key :

brew uninstall --force homebrew

b. Enter the following command and press Return to reinstall Homebrew:

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

This command will download and install the latest version of Homebrew. After restarting the Terminal application, you should be able to use the brew command without any problems.

2. Add Brew to the PATH environment variable

Most likely Homebrew could not be added to the PATH variable during the installation process, meaning your shell cannot locate the Homebrew executable.

You can fix this problem by manually adding Homebrew to your PATH through Terminal. The command varies slightly depending on whether the 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 has been successfully added to the PATH variable with the following command:

echo $PATH

How to fix Mac Homebrew error 'zsh: command not found: brew' Picture 2How to fix Mac Homebrew error 'zsh: command not found: brew' Picture 2

This will display all executable binaries that Terminal can find. If Homebrew is in the list, it means Terminal was able to successfully locate the Homebrew executable.

3. Install Xcode Command Line Tools

How to fix Mac Homebrew error 'zsh: command not found: brew' Picture 3How to fix Mac Homebrew error 'zsh: command not found: brew' Picture 3

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. Some users have reported that Homebrew cannot function without Xcode Command Line Tools installed. You can install by entering the following command into Terminal and pressing Return :

xcode-select --install

You can then verify the installation with the following command:

xcode-select -p

If the installation is successful, you will get the following output after entering the command:

/Library/Developer/CommandLineTools

Homebrew offers a number of useful applications and is an indispensable utility for every power Mac user. If you get the "zsh: command not found: brew" error, one of the troubleshooting steps the article discussed above will resolve the problem and let you enjoy the best package manager available. for macOS.

5 ★ | 1 Vote