According to the Homebrew site, I tried:
brew install wget
But I get this error:
-bash: brew: command not found
I checked /usr/local/bin but didn’t find brew there. I also added this to my .bashrc:
export PATH=/usr/local/bin:$PATH
Still, the brew command not found issue persists. How can I resolve this and install Homebrew correctly?
Been working on Macs for about 6 years now, and yeah, I’ve definitely run into this before…
I hit the “brew command not found” issue a while back and realized I had assumed Homebrew came pre-installed with macOS (it doesn’t). What fixed it for me was simply running the official install script directly from Homebrew’s website:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Right after that, the brew
command worked without a hitch. So before diving into any troubleshooting, just double-check whether Homebrew is actually installed.
Been dealing with terminal setups for over a decade now, and yeah, @mark-mazay spot on. Just wanted to add…
Even if you did install it, you might still get the “brew command not found” error if your shell config isn’t pointing to the right path. Happened to me because I edited .bashrc
, but my Mac was using zsh (.zshrc
), which is now the default.
Especially on Apple Silicon (M1/M2), Homebrew installs to /opt/homebrew
, not /usr/local
. You can fix this by adding the correct path to your .zshrc
:
export PATH="/opt/homebrew/bin:$PATH"
Then run:
source ~/.zshrc
That change made the brew
command work instantly for me.
I troubleshoot dev setups all the time, and honestly, this one crops up more often than you’d expect…
Just to build on what both of you said, if you’re still seeing “brew command not found”, even after install and setting your PATH, it’s worth checking if the terminal session actually picked up the changes.
You can verify the brew
location with:
which brew
If that returns nothing, try restarting the terminal (or the entire machine). Also, make sure you’re not editing the wrong shell file, .bashrc
, .zshrc
, .bash_profile
— they can override each other. Sometimes it’s just one overlooked config line that causes the problem.