➜  ~ /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

当前回答

基本上你的自制程序保存在/opt/homebrew/,而不是/usr/local/....路径

打开主目录下的.bash_profile并添加:

export PATH=/opt/homebrew/bin:$PATH

并重新启动终端。你会让它运行起来的。

其他回答

也许不是很明显,但是除了上面的步骤之外,检查您的.zshprofile是否被任何多余的引号损坏。您还应该关闭所有终端实例。

基本上你的自制程序保存在/opt/homebrew/,而不是/usr/local/....路径

打开主目录下的.bash_profile并添加:

export PATH=/opt/homebrew/bin:$PATH

并重新启动终端。你会让它运行起来的。

如果您使用的是WSL2,请确保遵循linuxbrew的最终linux安装说明。

test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.bash_profile && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.profile

只需在主目录中添加export PATH=/opt/homebrew/bin:$PATH即可

如果需要重新启动,或者重新打开终端

编辑.zshrc文件:

nano .zshrc

并在文件的开头添加以下内容:

export PATH=/opt/homebrew/bin:$PATH

保存并运行:

source ~/.zshrc