Error Installing Homebrew - Brew Command Not Found

Fixing zsh command not found: brew? (installing Homebrew)

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.

Installing Homebrew on macOS

It's on the top of the Homebrew homepage.

From a Terminal prompt:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

The command brew install wget is an example of how to use Homebrew to install another application (in this case, wget) after brew is already installed.


Historic...

Before about 2020, the command given on the Homebrew page was:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Error Installing Homebrew - Brew Command Not Found

The warning is telling you what is wrong. The problem is that brew is kept in /usr/local/bin

So, you can try /usr/local/bin/brew doctor

To fix it permanently alter your bash profile (.bashrc or .profile in your home directory) and add the following line:

export PATH=/usr/local/bin:$PATH

How do I install homebrew on macOS? Error: -bash: $: command not found

You're copying the leading $, which is the prompt, not part of the command. It is to indicate "this is something you should paste on the commandline." The actual command is:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

If you click the "clipboard" icon at brew.sh, it'll copy the correct command to your clipboard.

Pointer to clipboard icon at brew.sh

Note that this "leading $ prompt" indicator is used throughout the brew.sh site (and is very common in unix-style documentation). So when you see $ brew install wget, that means to type "brew install wget" at the command prompt. It does not mean to type $.

How to Install Homebrew on Windows WSL Ubuntu, and fix zsh: brew command not found error

In a wsl environment, brew is installed at location: /home/linuxbrew/.linuxbrew/ which is not part of the path.

So we simply need to add that to path, and it works. I am using zsh as my shell, so I add these lines to my ~/.zshrc file (in ubuntu file system) :

export BREW_HOME="/home/linuxbrew/.linuxbrew/bin"
export PATH="$PATH:$BREW_HOME"

Homebrew is not found on apple silicon

Run:

echo $SHELL

If your shell shown is zsh, do this:

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

If yor shell is bash, run this:

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

If the result is csh, run this command:

/opt/homebrew/bin/brew shellenv >> ~/.cshrc


Related Topics



Leave a reply



Submit