在我的旧 Intel Mac 上,这个过程非常顺利,但现在有些步骤我不知道怎么做。我很累了,完全不懂如何安装 Homebrew,而且我读了很多资料都没有帮助。显然,苹果芯片的 Mac 的路径应该是不同的。
在Apple Silicon上安装Homebrew,步骤如下:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
在我的情况下,安装时出现错误,我只需要重新安装,然后显示:安装成功!警告:/opt/homebrew/bin不在您的路径中。
touch ~/.zshrc
然后使用TextEdit打开它进行编辑(是一个隐藏文件。您可以使用shift + command + . 显示隐藏文件)
在.zshrc的末尾添加这行内容
export PATH=/opt/homebrew/bin:$PATH
在终端中运行此命令以使其可用:source ~/.zshrc
brew help
这对我来说是使 homebrew 永久有效的方法。
或者做:
- Add Homebrew to your PATH in ~/.zprofile:
echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> ~/.zprofile
eval $(/opt/homebrew/bin/brew shellenv)
"Then open it to edit with TextEdit (Is a hidden file. You can show hidden files with shift + command + . )"我已经使用了以下命令:
open .zshrc
如果您只想使用终端命令,可以使用此方法。谢谢! - A. Yasar G.看起来现在不需要触摸、源和导出。在终端中运行下面的命令
似乎现在不需要“触摸、源和导出”的操作了。请在终端中运行以下命令。
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
跟随终端本身显示的指示进行操作。具体如下所示:
==> Next steps:
Run these two commands in your terminal to add Homebrew to your PATH:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/xxx/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
接下来,brew help
.zprofile
或.zshrc
中,因为它允许Homebrew将自身添加到路径并设置MANPATH
和INFOPATH
。它对随Homebrew升级而带来的更改具有弹性。 - Rusty Brown Nail前往 Homebrew 并获取安装命令:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
在终端中请求时,请按“return”以完成安装
安装完成后,终端将生成要执行的下一个命令:
==> Next steps:
Run these two commands in your terminal to add Homebrew to your PATH:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/$yourdevicename/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
Run brew help to get started
- Further documentation:
https://docs.brew.sh
前往Homebrew网页
复制“安装Homebrew”下提供的脚本。
通过Spotlight搜索打开终端
使用Spotlight搜索(按Command + 空格键)打开终端。
现在在终端中粘贴从Homebrew网站复制的脚本。
安装过程中会提示您点击return按钮,所以不要担心。对于M1芯片的MacBook Air,安装成功后Homebrew将无法正常工作。
它将显示一些路径警告,即警告:/opt/homebrew/bin未包含在您的PATH中
==>现在在同一个终端窗口中,我们将在主目录中创建.zshrc文件。
因此,请运行该命令以创建此目录:
touch .zshrc
现在我们将打开主目录
为了打开主目录,我们会从Dock中打开Finder,并确保它是活动应用程序。
现在,在Finder应用程序中,我们将按下打开主目录的按钮,即 command+shift+H。
这样,Finder将打开主目录。
现在,由于 .zshrc 是一个隐藏文件,因为我们使用上面的终端创建它。
要访问隐藏文件,请按下按钮,即 shift + command + .
完成后,找到 .zshrc 文件并单击“用文本编辑器选项进行编辑”。
在 .zshrc 文件中设置路径
现在,在行末粘贴此内容-
export PATH=/opt/homebrew/bin:$PATH
source ~/.zshrc
brew
当您输入此命令后,您将会知道 Homebrew 现在正在工作!
现在您可以使用 Homebrew 安装 git 或其他您想要的内容...
祝大家有愉快的一天!
打开终端并复制以下命令
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
使用touch创建一个新的空文件
touch .zshrc
现在用vim编辑器打开该文件
vim .zshrc
现在按i进入编辑模式并输入
export PATH=/opt/homebrew/bin:$PATH
然后按esc,再输入:wq
现在我们成功设置了brew,要永久地测试,请输入
brew或brew help
将此行添加到默认主目录下的 .zshrc 文件中。
export PATH=/opt/homebrew/bin:$PATH
Lena Bru和Camilo Lizarazo Olaya给出的答案是解决方案。
特别是最后的代码块。
- Add Homebrew to your PATH in ~/.zprofile:
echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> ~/.zprofile
eval $(/opt/homebrew/bin/brew shellenv)
终端的完整返回值为
Warning: /opt/homebrew/bin is not in your PATH.
Instructions on how to configure your shell for Homebrew
can be found in the 'Next steps' section below.
==> 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 (nor will any be during this install run).
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
https://github.com/Homebrew/brew#donations
==> Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/bohuang/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
- Run brew help to get started
- Further documentation:
https://docs.brew.sh
已被Homebrew官方团队接受。
我在我的新Macbook Pro(芯片为Apple M1 Pro)上安装了Homebrew。安装成功,并输出了与两个命令行相同的提示。
如果你遇到了英特尔芯片错误
xcrun: error: unable to load libxcrun (dlopen(/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib, 0x0005): tried: '/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libxcrun.dylib' (no such file)).
那么您必须修复命令行工具(CLT)。 我所做的是以下解决方案(来自此处):
我建议的是卸载命令行工具(CLT),然后以官方方式重新安装它们(source)。
因此,请执行(source):
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select -p
输出
xcode-select: error: unable to get active developer directory, use `sudo xcode-select --switch path/to/Xcode.app` to set one (or see `man xcode-select`)
然后重新安装命令行工具(CLT):
xcode-select --install
然后同意它,几分钟后应该会下载。下载可能需要一些时间。对我来说大约13分钟。
之后,您与PyCharm、git、brew和其他工具的问题将得到解决。
在解决了这个问题之后——当我尝试安装brew时遇到了问题——请按照这里的顶部答案建议做:https://dev59.com/yFEG5IYBdhLWcg3wZcZh#67271753,简而言之,运行bash安装brew,并确保它已正确添加到您的PATH环境变量中。
export PATH=/opt/homebrew/bin:$PATH
编辑完成后,按esc键,输入:wq保存
然后运行命令
exec zsh
瞧,brew已经准备好了。
谢谢,如果有帮助请告诉我。