How to fix command not found brew (bash, zsh) on macOS Terminal


[email protected] bin % brew
zsh: command not found: brew
[email protected] bin % 

If you get brew command not found error when you run a brew command on zsh (or any other shell like bash) on macOS Terminal, there could be few reasons, 1) you many have not installed brew - if so please follow this article - Installing Brew, 2) you many not have set the PATH for brew,

Brew command not found fix
Brew command not found fix

Adding brew to PATH variable:

  1. Open Terminal,
  2. Go to /opt/homebrew/bin/ (if you do not find this path - brew is not installed - Article - Installing Brew),
  3. Run: export PATH=$PATH:/opt/homebrew/bin/opt/homebrew/bin/,
  4. Try running the brew version command to validate,
[email protected] % brew --version
Homebrew 3.0.0
Homebrew/homebrew-core (git revision f1b2a2; last commit 2021-02-10)
[email protected] / % brew help
Example usage:
  brew search [TEXT|/REGEX/]
  brew info [FORMULA...]
  brew install FORMULA...
  brew update
  brew upgrade [FORMULA...]
  brew uninstall FORMULA...
  brew list [FORMULA...]

Troubleshooting:
  brew config
  brew doctor
  brew install --verbose --debug FORMULA

Contributing:
  brew create [URL [--no-fetch]]
  brew edit [FORMULA...]

Further help:
  brew commands
  brew help [COMMAND]
  man brew
  https://docs.brew.sh