➜  ~ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
-e:77: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040677
It appears Homebrew is already installed. If your intent is to reinstall you
should do the following before running this installer again:
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
The current contents of /usr/local are bin CODEOFCONDUCT.md etc git lib Library LICENSE.txt munki README.md sbin share .git .github .gitignore
➜  ~ brew install maven
zsh: command not found: brew

当前回答

在我的示例中,我将以下行添加到~/.zshrc

eval "$(/opt/homebrew/bin/brew shellenv)"

其他回答

在Apple M1的fish shell中,我必须将/opt/homebrew/bin添加到fish_user_paths全局环境中。我必须手动这样做,因为set -U fish_user_paths /opt/homebrew/bin $fish_user_paths got

设置:通用变量fish_user_paths被同名的全局变量遮蔽。

因为你正在使用zsh,你需要添加路径到你的。zshrc文件:

vim ~ / . zshrc

Add:

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

在我的示例中,我将以下行添加到~/.zshrc

eval "$(/opt/homebrew/bin/brew shellenv)"

我只是做了echo 'eval ' $(/home/linuxbrew/。linuxbrew / bin /酿造shellenv)' >> ~/。zshrc,因为我正在使用哦-我的zsh。这样做之后应该就可以使用冲泡了。

在我的MacBook (macOS Big Sur V 11.0.1)安装Homebrew后,我也遇到了同样的问题。

安装完成后,在控制台中会显示应该做什么:

==>下一步: -将Homebrew添加到/Users/USER/.zprofile中的PATH: echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/USER/.zprofile . sh Eval $(/opt/homebrew/bin/brew shellenv) -运行“brew help”开始

按顺序执行这两个命令,会将brew命令添加到PATH:

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

eval "$(/opt/homebrew/bin/brew shellenv)"