如何在/opt/目录下安装Homebrew?

15
我正在使用新款M1 MacBook Pro。我正在尝试通过Homebrew安装具有本地Apple Silicon支持的gtk + 3。首先,它告诉我:无法在Intel默认前缀(/usr/local)上在ARM处理器上安装Homebrew!请在/opt/homebrew中使用“替代安装”之一创建新安装,该信息来源于https://docs.brew.sh/Installation。您可以使用以下命令将以前安装的配方列表迁移过来: brew bundle dump。我尝试通过Rosetta 2运行终端,但是gtk+3需要ARM支持才能安装,因此没有成功。我尝试手动将代码行解压缩到/opt/中的docs.brew.sh,但是它告诉我我没有权限。我尝试用sudo,但没有成功。有什么帮助吗?
brew install gtk+3  
Updating Homebrew...
==> Auto-updated Homebrew!  
Updated 1 tap (homebrew/core).  
==> New Formulae  
libbsd  
==> Updated Formulae  
Updated 18 formulae.  
错误:无法在Intel默认前缀(/usr/local)上的ARM处理器中通过Homebrew安装! 请使用“替代安装”之一,在/opt/homebrew中创建一个新的安装程序。 您可以使用以下命令迁移先前安装的公式列表: brew bundle dump
oresttokovenko@Orests-MacBook-Pro-2 Homebrew % sudo chmod 755          
Password:
usage:  chmod [-fhv] [-R [-H | -L | -P]] [-a | +a | =a  [i][# [ n]]] mode|entry file ...
    chmod [-fhv] [-R [-H | -L | -P]] [-E | -C | -N | -i | -I] file ...
oresttokovenko@Orests-MacBook-Pro-2 Homebrew % https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
zsh: no such file or directory: https://github.com/Homebrew/brew/tarball/master
tar: could not chdir to 'homebrew'

oresttokovenko@Orests-MacBook-Pro-2 Homebrew % curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   128  100   128    0     0    254      0 --:--:-- --:--:-- --:--:--   255
  0 1979k    0   598    0     0    682      0  0:49:32 --:--:--  0:49:32   682tar: could not chdir to 'homebrew'

  1 1979k    1 33478    0     0  34728      0  0:00:58 --:--:--  0:00:58  364k
curl: (23) Failed writing body (0 != 1370)
oresttokovenko@Orests-MacBook-Pro-2 Homebrew % sudo curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   128  100   128    0     0    348      0 --:--:-- --:--:-- --:--:--   348
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0tar: could not chdir to 'homebrew'

  1 1979k    1 34138    0     0  41887      0  0:00:48 --:--:--  0:00:48  129k
curl: (23) Failed writing body (0 != 1370)

你无法使用sudo创建/opt/homebrew吗? - Warren Burton
我用sudo再次尝试,开始工作了,然后停止了,显示"tar: Error exit delayed from previous errors."。 - Orest Tokovenko
4个回答

23

我使用了Noah Rubin编写的脚本;

/bin/bash -c "$(curl -fsSL https://gist.githubusercontent.com/nrubin29/bea5aa83e8dfa91370fe83b62dad6dfa/raw/48f48f7fef21abb308e129a80b3214c2538fc611/homebrew_m1.sh)"

效果非常好!这是他在这个主题上的YouTube视频,以获取更多信息;https://youtu.be/nv2ylxro7rM

编辑:忘记提到,此脚本将Homebrew安装到/opt/homebrew


这个链接视频演示了何时使用Rosetta 2以及何时本地运行。我没有找到其他任何详细信息,这似乎很重要。 - Kay V
无法在 /usr/local/var/homebrew/locks 中创建更新锁! 通过运行以下命令修复权限: sudo chown -R $(whoami) /usr/local/var/homebrew 警告:您的 HOMEBREW_PREFIX 设置为 /usr/local,但 HOMEBREW_CELLAR 设置为 /opt/homebrew/Cellar。您当前的 HOMEBREW_CELLAR 位置将停止访问所有瓶子。 错误:无法在 Homebrew ARM 处理器 Intel 默认前缀 (/usr/local) 中安装! 请使用 https://docs.brew.sh/Installation 上的“替代安装”之一,在 /opt/homebrew 中创建新安装。 您可以使用以下命令迁移先前安装的公式:brew bundle dump - sejn
如果我运行brew bundle dump,会有什么影响? - sejn

4

我在Rosetta终端下运行解决了它

  1. 在“实用工具”文件夹中找到终端应用程序(Finder > 转到菜单 > 实用工具)

  2. 选择Terminal.app并右键点击,然后选择“复制” 将复制的终端应用程序重命名为容易识别的名称,例如'Rosetta Terminal'

  3. 现在选择新命名的“Rosetta Terminal”应用程序,右键点击并选择“获取信息”(或按Command+i)

  4. 勾选“使用Rosetta打开”的框,然后关闭“获取信息”窗口 如常运行“Rosetta Terminal”,将完全支持Homebrew和其他x86命令行应用程序。


You are using macOS 11.0. We do not provide support for this released but not yet supported version. You will encounter build failures with some formulae. Please create pull requests instead of asking for help on Homebrew's GitHub, Twitter or any other official channels. You are responsible for resolving any issues you experience while you are running this released but not yet supported version. Error: gtk+3 dependencies not built for the x86_64 CPU architecture: python@3.9 was built for arm64 – - Orest Tokovenko
2
这个解决方法对我很有效,我也无法弄清楚如何按照官方文档建议在opt/homebrew中安装Homebrew。 - Federico

0

对我来说,这个教程非常有帮助。基本上是重新安装Homebrew并将其添加到.zprofile中。


0

仅供现在遇到此问题的任何人参考,我多次遇到了curl: (23) Failed writing body (0 != 1370)错误,直到我意识到我是从我的主目录运行curl/tar命令。如果我cd进入/opt然后运行该命令,它将按预期工作。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接