There are a few tools that can help you solve zsh: command not found: brew. The homebrew is one of the best tools that can fix the error. Homebrew is popularly known as brew, which is a short form. It is a free and open-source tool for Linux and Mac operating systems. It is a command-line utility, which is lightweight and built on Ruby programming language.
Let’s shed light on how to fix zsh: command not found: brew
How to fix zsh: command not found: brew
This error occurs when a brew command is given on the Mac. There are two reasons that can cause the error; the brew is not installed in your Mac system, no directory listed in the path, or selection of the wrong file path.
Method 1 – Reinstall Brew
As mentioned above brew is Homebrew, which is software. When the software doesn’t work the way it should, then you can just uninstall it and then reinstall it. To completely uninstall the software along with deleting the cache, you can do it by opening the terminal on Mac and typing a command. Command is:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
Once you successfully uninstall the software, brew, just restart your system. The next step is to reinstall the homebrew which can be done from their website. Paste the below code to install it:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Method 2 – For M1 Chip – Install the ARM version
In the case, you are using Mac that is powered by the Chip M1, an instruction is shown by your device to add homebrew to the zsh configuration file having the name .zprofile. In this, you have to install brew in /opt/Homebrew instead of the path /usr/local/Homebrew. Have a look at the install Arm version on the M1 device
666@XXX-MacBook-Pro ~ % /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh”
…
Next steps:
- Add Homebrew to your PATH in /Users/668/.zprofile:echo ‘eval $(/opt/homebrew/bin/brew shellenv)’ >> /Users/668/.zprofile eval $(/opt/homebrew/bin/brew shellenv)
- Run `brew help` to get started
- Further documentation: https://docs.brew.sh 666@XXX-MacBook-Pro ~ % brew install –cask google-chrome zsh: command not found: brew
The brew can also be added to the .zshrc using the following command
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> $HOME/.zshrc
Conclusion
In this article, we have highlighted how to fix zsh: command not found: brew in a simple way so that you can solve it. Two methods have been discussed; you can try according to the issue you are facing. I hope you can get rid of this error!
I wish you All The Best!