Tutorials

[Resolved] “zsh: command not found: brew” Error on Mac

"zsh: command not found: brew" Error

If you encounter the “zsh: command not found: brew” error on your Mac, it typically means that the Homebrew package manager is either not installed or not properly configured in your system’s PATH. Homebrew is an essential tool for many developers, allowing you to easily install and manage software packages. This guide will walk you through the steps to resolve the error and ensure Homebrew is working seamlessly on your Mac.

How to Resolve the “zsh: command not found: brew” Error

[Resolved] "zsh: command not found: brew" Error on Mac 1

To fix the “zsh: command not found: brew” error, follow these clear steps to ensure Homebrew is properly installed and configured.

Step 1: Confirm Homebrew Installation

First, let’s confirm that Homebrew is installed on your system. If you haven’t installed it yet, follow these steps to install it:

  1. Open your terminal.
  2. Run the following command to install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. Once the installation is complete, the terminal will display the next steps to take. These steps typically include adding Homebrew to your PATH.

Step 2: Add Homebrew to Your PATH

After installation, if you still see the “command not found” error, it’s likely that the Homebrew binary isn’t in your shell’s PATH. Here’s how to fix it:

  1. Open your .zshrc file. This file is located in your home directory (~):
nano ~/.zshrc
  1. Add the following line at the beginning of the file to include Homebrew’s path:
export PATH="/opt/homebrew/bin:$PATH"

Note: If you’re using an Apple Silicon Mac (M1, M2, etc.), Homebrew is installed in /opt/homebrew/ by default. If you’re on an Intel Mac, it might be installed in /usr/local/bin/.

  1. Save the file and exit nano by pressing Control + O (to save) and Control + X (to exit).
  2. Now, apply the changes by sourcing the .zshrc file:
source ~/.zshrc

Step 3: Verify the Installation

After sourcing the .zshrc file, you can check if Homebrew is accessible by running:

brew --version

If everything is set up correctly, this should return the installed version of Homebrew.

Step 4: Restart Your Terminal (Optional)

If you’re still encountering issues, try closing your terminal and opening it again. This can help apply changes that may not take effect immediately.

Troubleshooting

If you continue to see issues, here are some additional checks and steps:

  • Correct Path for Homebrew: Ensure you’re adding the correct path to .zshrc. If you’re unsure whether Homebrew is installed in /opt/homebrew or /usr/local/bin, you can locate Homebrew with:
which brew
  • Reinstall Homebrew: If none of the steps work, consider uninstalling and reinstalling Homebrew. To uninstall, run:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

Then, re-run the installation command from Step 1.

By carefully following these steps, you should be able to resolve the “zsh: command not found: brew” error and get Homebrew running smoothly.

Conclusion

With these steps and troubleshooting tips, you now have the resources to address and resolve the “zsh: command not found: brew” error effectively. Ensuring that Homebrew is installed correctly and its path is properly configured will enable a seamless experience with this powerful package manager. By following the guide above, you can quickly get back to managing your software installations with confidence and ease.

Keep reading

First project offer

Get 50% off your first project

The discount applies to your first fixed quote only. Send your brief and get your fixed quote by email.

Step 1 of 3 · What do you need?

Get a fixed quote

50% off your first project. Applies to your first fixed quote only.

What do you need?

Pick an option to see its starting price and typical timeline.