根据 Homebrew 站点,要安装它,我需要输入:
brew install wget
我收到一条错误消息:
-bash: brew: command not found
找到 this answer。但是,问题是我在 /usr/local/bin
中看不到 brew
。
我将以下行添加到我的 .bashrc
文件中
export PATH=/usr/local/bin:$PATH
仍然收到 command not found
错误。
如何在 macOS 上安装 Homebrew?
zsh
是 mac 中的新默认设置,我们被要求执行 /bin/bash
不是很可疑吗?如果答案失败,这可能会有所帮助:apple.stackexchange.com/questions/419724/…
sudo rm -rf /usr/local/HomeBrew
它位于 Homebrew homepage 的顶部。
从终端提示:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
命令 brew install wget
是在 brew 安装后如何使用 Homebrew 安装另一个应用程序(在本例中为 wget
)的示例。
历史性...
大约在 2020 年之前,Homebrew 页面上给出的命令是:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
如果您使用的是 m1 chip mac,请在安装 homebrew 后运行以下命令并再次打开终端:
echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.zshrc
检查是否安装了 Xcode:
$ gcc --version
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
$ brew doctor
$ brew update
http://techsharehub.blogspot.com/2013/08/brew-command-not-found.html“点击此处获取确切的说明更新”
brew doctor
之后安装 xcode 命令行开发人员工具
如何为 Homebrew 设置 Mac
步骤1
检查您是否已经安装了 Xcode。在终端中运行以下命令
/usr/bin/xcodebuild -version
它将打印以下示例输出:
Xcode 12.3 构建版本 12C33
第2步
现在打开 Xcode:
选择首选项 选择位置选项卡 现在在命令行工具中从下拉菜单中选择您的 Xcode 版本
第 3 步
在终端运行以下命令:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
注意:如果您有 M1 Chip Mac 运行以下命令,关闭终端并再次打开终端
echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.zshrc
export
应该转到 .zshrc
还是 .bash_profile
取决于您的登录 shell。新用户帐户默认使用 Zsh,但 Bash 仍然是一个选项,如果您在默认使用 Bash 的旧版本 macOS 上创建帐户,或者您随后明确将 Bash 配置为您的 shell,则可能是您的 shell。
zsh
是 mac 中的新默认设置,我们被要求执行 /bin/bash
是不是非常可疑?
对于带有 Apple Silicon (M1) 的 Mac,首先导出路径并输入 brew 命令。
export PATH=/opt/homebrew/bin:$PATH
brew
我可能迟到了,但是有一个很酷的网站,你可以在其中搜索软件包,它会列出安装这些东西的必要命令。 BrewInstall 是网站。
但是,您可以使用以下命令安装 wget:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install wget
希望这可以帮助 :)
对于 m1 mac,使用此命令并重新启动终端。
echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.zshrc
开箱即用的 MacOS High Sierra 10.13.6
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
给出以下错误:
curl 默认使用证书颁发机构 (CA) 公钥(CA 证书)的“捆绑”执行 SSL 证书验证。如果默认捆绑文件不够用,您可以使用 --cacert 选项指定备用文件。如果此 HTTPS 服务器使用捆绑包中表示的 CA 签名的证书,则证书验证可能由于证书问题而失败(证书可能已过期,或者名称可能与 URL 中的域名不匹配)。如果您想关闭 curl 对证书的验证,请使用 -k(或 --insecure)选项。 HTTPS-proxy 有类似的选项 --proxy-cacert 和 --proxy-insecure。
解决方案:只需将 ak 添加到您的 Curl Options
$ ruby -e "$(curl -fsSLk https://raw.githubusercontent.com/Homebrew/install/master/install)"
Brew 现在已在 Bash 中重写!
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
首先,通过在 mac 终端中粘贴命令来安装自制软件
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
然后编辑你的 .bashrc 文件
vi .bashrc
将以下命令粘贴到最后并保存
export PATH=/opt/homebrew/bin:$PATH
要保存,只需键入 :wq
并按 Enter
如果 bashrc 文件不存在,则只需创建然后编辑该文件,以创建类型
touch ~/.bashrc
然后只需运行命令
source ~/.bashrc
现在尝试使用 brew 命令希望它现在可以工作
更新:如果您使用的是 M1 mac,那么在安装自制软件后,只需运行下面提到的命令并重新加载终端
echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.zshrc
这是一个将 homebrew 安装程序包装在 bash 函数中的版本,该函数可以从您的部署脚本中运行:
install_homebrew_if_not_present() {
echo "Checking for homebrew installation"
which -s brew
if [[ $? != 0 ]] ; then
echo "Homebrew not found. Installing..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
else
echo "Homebrew already installed! Updating..."
brew update
fi
}
如果尚未安装自制公式,另一个功能将安装它:
brew_install () {
if brew ls --versions $1 > /dev/null; then
echo "already installed: $1"
else
echo "Installing forumula: $1..."
brew install $1
fi
}
一旦定义了这些函数,就可以在 bash 脚本中按如下方式使用它们:
install_homebrew_if_not_present
brew_install wget
brew_install openssl
...
在使用 M1 处理器的 mac BigSur 上安装 Homebrew 时,我遇到了同样的 brew command not found 问题。
I - 如果尚未安装 XCode,请安装它。
II - 在 Finder 中选择 terminal.app。
III - RMB 点击终端并选择“获取信息”
IV - 选择使用 Rosetta 打开复选框。
V - 关闭所有打开的终端窗口。
VI - 打开一个新的终端窗口并安装 Hobebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
VII - 测试 Homebrew 安装。
IIX - 取消选中 Open using Rosetta 复选框。
如果运行后仍然报错,
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
然后尝试从 https://developer.apple.com/download/more/ 为您的特定 Mac 操作系统和 Xcode 版本下载并安装命令行工具。
然后尝试运行,
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
接着
brew install node
node
的建议在这里完全是虚假的。该问题询问如何安装 brew
,而不是 node
。
打开终端并输入以下命令。安装:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
卸载:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
输入 brew 命令后安装完成:
brew install wget
brew install node
brew install watchman
...
...
您可以使用以下命令安装 brew。
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
但是,在使用它时,您会收到警告说它现在已弃用自制安装程序。建议改用 Bash。
https://i.stack.imgur.com/iTbuE.png
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
https://i.stack.imgur.com/M31C1.png
如果您在代理下,以下命令将不起作用。
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
而是用户关注 -
ruby -e "$(curl -x http://DOMAIN%5cUSER_NAME:PASSWORD@PROXY:PORT -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
请注意,我们必须使用 %5c 而不是 "\" 类似地,如果您的密码有任何特殊字符,请将其替换为 unicode,例如 @ 使用 %40 请参阅此 Unicodes
用您自己的参数替换上面的命令
域 - 您的域
USER_NAME - 您的用户名
PASSWORD - 密码
代理 - 10.10.10.10
港口 - 8080
macOS 大苏尔
必须将此添加到 Terminal
cmd 以使 Brew
运行。
在 /Users/*username/.zprofile 中将 Homebrew 添加到 PATH: echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/*username/.zprofile eval $(/opt/homebrew/bin /brew shellenv)
*username = 你的本地机器用户名
解决“ -bash: brew: command not found ”
在 /Users//.bash_profile 中将 Homebrew 添加到您的 PATH 中:
echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users//.bash_profile
eval $(/opt/homebrew/bin/brew shellenv)
在您的终端中添加以下内容并单击输入,然后按照终端中的说明进行操作。 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
不知道为什么没有人提到这个:当你从官方网站运行安装命令时,在最后几行你会看到类似下面的内容,你需要按照 ==> Next steps:
==> Installation successful!
==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
https://docs.brew.sh/Analytics
No analytics data has been sent yet (or will be during this `install` run).
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
https://github.com/Homebrew/brew#donations
==> Next steps:
- Add Homebrew to your PATH in /Users/{YOUR USER NAME}/.bash_profile:
echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/{YOUR USER NAME}/.bash_profile
eval $(/opt/homebrew/bin/brew shellenv)
这适用于 bash
外壳。对于每个不同的 shell,您会看到不同的步骤,但步骤的来源是相同的。
在我尝试了所描述的所有内容后,我查看了 /usr/local/etc/ 中 brew 的文件夹权限。不知何故更改了权限,我无法打开该文件夹。我用与其他文件夹相同的权限更改了文件夹权限(使用 chmod),并且 brew 开始工作。
这是脚本:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
不定期副业成功案例分享
ruby -e "$(curl -fsSL bit.ly/brew-install)"
Add Homebrew to your PATH in /Users/username/.bash_profile: echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/username/.bash_profile eval "$(/opt/homebrew/bin/brew shellenv)"
next steps
部分,有2个步骤可以运行:echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/[user]/.zprofile
和eval "$(/opt/homebrew/bin/brew shellenv)"
Error: homebrew-core is a shallow clone. homebrew-cask is a shallow clone.