0

I have macOS Monterey(v12.3) and had installed brew with exact guidelines shown in youtube videos. But brew commands work only if I run in the same terminal session. When I restart the terminal and try to run the brew command it shows the following error:

zsh: command not found: brew

I have tried to install the brew multiple time but every time same thing happens. I am new to MacOS. Please help.

screenshot

Saurabh
  • 3
  • 1

1 Answers1

1

On Apple Silicon machines, Homebrew installs itself in /opt/homebrew rather than in /usr/local/bin as on Intel-based machines. I suspect that you are running on a Silicon machine. The /opt/homebrew/ directory isn't part of the standard PATH. To accommodate this, it is suggested to setup a ~/.zprofile:

Add Homebrew to your PATH in ~/.zprofile:

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

(the first line adds the code to ~/.zprofile and the second runs it in the current shell)

Stéphane Chazelas
  • 522,931
  • 91
  • 1,010
  • 1,501
JRFerguson
  • 14,570
  • 3
  • 34
  • 40