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

code2care@mac bin % brew
zsh: command not found: brew
code2care@mac 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,
code2care@mac % brew --version
Homebrew 3.0.0
Homebrew/homebrew-core (git revision f1b2a2; last commit 2021-02-10)
code2care@mac / % 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...]

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

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

Further help:
  brew commands
  brew help [COMMAND]
  man brew

Recent Posts:

Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.