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

当前回答

Ubuntu 20.04的解决方案

安装brew后: /bin/bash -c $(curl - ssl https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 然后运行它所说的(这对我来说什么都没有,只是每次我运行它时都向.zprofile添加行): 回显“eval”$(/home/linuxbrew/。linuxbrew / bin /酿造shellenv)' >> /home/blcuser/.zprofile . ' eval”(/ home / linuxbrew /美元。linuxbrew / bin /酿造shellenv)” 在关闭终端之前,复制输出: 回声路径美元 应该类似于这个:

/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

我们需要的是酿造路径也就是预览路径的这一部分(对你来说可能是另一条路径)

/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin

打开NEW终端,尝试使用以下命令构建整个第一条路径:

应该像这样:<brew_path>:$PATH

对我来说是:echo /home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:$PATH

应该输出我们在4上输出的第一个完整路径。

打开.zshrc文件(我的是在home隐藏文件) 在.zshrc文件的开头,添加我们在5.上构建的内容: 导出路径= / home / linuxbrew / .linuxbrew / bin: / home / linuxbrew / .linuxbrew / sbin:美元的道路 保存并重新启动终端 检查正在工作的: 酿造的医生

默认情况下,您应该总是以新终端启动设置和酿造。

其他回答

你的电脑上已经安装了自制软件。你需要像这样修改你的PATH:

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

或者从起始点执行brew:

/usr/local/bin/brew install maven

更新2023

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

编辑.zshrc文件:

nano .zshrc

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

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

保存并运行:

source ~/.zshrc 

我在macOS Big Sur(11.0.1)上遇到了类似的问题。在我的例子中,homebrew保存在/opt/homebrew/,而不是/usr/local/....

所以我补充道

导出路径= / opt /组装/ bin:美元的道路

到我的主目录中的.zshrc文件,并且ZSH shell能够找到brew命令。

请访问Homebrew官方网站。

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

下一个步骤:

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

尝试:brew install hello