I am trying to install Homebrew onto my M1 Mac. My default shell is zsh and I want to keep it that way. I ran:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
and it said the installation was successful however after trying the command brew doctor
and brew help
both returned the error zsh: command not found: brew
I don't know a whole lot about shells or programming so anything I can try would be helpful.
I then was about to try un/re installing it and ran:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
but a warning came up to migrate to this command:/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
this leads me to believe maybe it is just located in the wrong shell?
If the zsh shell that Apple provides in Mac OS X is out of date, as it has been in Yosemite and El Capitan, it's trivial to install the latest version, available on homebrew . Here's a couple of steps you need to do to make that your default. Read on, for how to do it.
Why Do I Get 'brew: command not found?” As mentioned above, one of the common reasons for getting the 'command not found brew' on Mac is due to the executable brew directory not being present in the 'PATH' environment.
cd /opt/homebrew/bin/
PATH=$PATH:/opt/homebrew/bin
cd
touch .zshrc
echo export PATH=$PATH:/opt/homebrew/bin >> .zshrc
Run the commands in that order in terminal, you'll be editing the path and creating the missing .zshrc file, exporting the path to this new file.
Now you should be able to use:
brew doctor
It should say: "Your system is ready to brew."
The bash deprecation warning from macOS can safely be ignored, or you can add export BASH_SILENCE_DEPRECATION_WARNING=1
to ~/.bashrc` to permanently silence it.
The initial brew setup script you're using was deprecated, you'll want to use /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
. I've skimmed that script and I think it's actually zsh compatible too, but not 100% sure. This will set it up to be accessible by any shells, as long as you have /usr/local/bin
in your PATH
. (export PATH="/usr/local/bin:$PATH"
in your ~/.zshrc
, or path+=/usr/local/bin
to use the zsh-specific syntax).
If you run which zsh
you should still see some output; if your default shell did get changed some, you can change it back using chsh -s /bin/zsh
.
EDIT:
I missed that you said you have an M1 Mac. According to the install script, the brew prefix is /opt/homebrew
on ARM-based Macs (apparently this is to work around needing sudo
for operations in /usr/local
). I don't have a new Mac to test with, but adding path+=/opt/homebrew/bin
to a new file at ~/.zshrc
should to the trick.
This has helped me:
Add Homebrew to your PATH in ~/.zprofile:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With