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

当前回答

对于此错误,zsh: command not found: brew

确保你已经安装了Brew,用这个(等待它完成安装) (编辑:在结尾添加了结尾引用)

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

然后遵循命令行上显示的NEXT STEPS,它应该显示如下所示

==> Next steps:
- Add Homebrew to your PATH in /Users/$USER/.zprofile:
    echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/$USER/.zprofile
    eval $(/opt/homebrew/bin/brew shellenv)

在相同的终端窗口上复制并粘贴第一行,然后按enter键

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

然后在同一终端窗口复制并粘贴最后一行,然后按enter键

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

最后,您应该能够使用brew帮助,如果有效,则意味着brew已正确安装并从ZSH运行。

其他回答

对于2022年10月6日的最新版本…

==>下一步:

在终端上运行以下三个命令,将Homebrew添加到PATH: echo '#为Homebrew设置路径,MANPATH等。>> /Users/tusharkhatri/.zprofile Echo 'eval "$(/opt/homebrew/bin/brew shellenv)">> /Users/tusharkhatri/.zprofile $(/opt/homebrew/bin/brew shellenv) 运行brew帮助来开始 进一步的文档: https://docs.brew.sh

可能会迟到,但肯定会有帮助。你必须首先安装brew。只要运行下面的命令就可以了:

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

我在Ubuntu和Arch Linux上也遇到了同样的问题。我通过在.zshrc文件中添加brew的bin文件夹路径来解决这个问题。

brew安装bin目录的路径是/home/linuxbrew/.linuxbrew/bin

将下面的行添加到~/。zshrc中 导出路径= / home / linuxbrew / .linuxbrew / bin:美元的道路

在此之后,打开一个新终端,brew命令将可用。

在您的.zshrc文件中,将路径添加到您的homebrew/bin,无论它可能在哪里。在我的例子中,homebrew安装在我的主目录中。 添加:

export PATH="/<path-to-homebrew-directory>/bin:$PATH"

重新启动终端,让它接收到.zshrc的更改

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

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