在Apple Silicon Arm M1上本地运行Homebrew

2020-11-23 11:40:30

这就是我如何使大多数配置与MacBook Pro(13,M1,2020)一起工作的方法在macOS Big Sur(11.0.1)上进行了测试创建于2020年11月17日最后更新:2020年11月18日

在撰写本文时(11月17日),此新体系结构尚未支持大多数应用程序,并且大多数应用程序将与Apple创建的Rosetta2一起运行。

首次在Mac上启动x86-64应用程序时,它将自动弹出并要求您安装Rosetta。该过程大约需要2分钟。然后,我可以打开这些应用程序,就像它们是为ARM mac本地构建的一样。

谣言说,在首次启动翻译时加载Microsoft Word需要20秒。但是,在我的计算机上打开它只需要6.89秒,这与我的16英寸MacBook Pro的加载时间一样快,甚至更快。我不知道是否是因为我在安装应用程序时已经对它进行了翻译,或者Microsoft / Apple进行了一些优化。对于其他应用,例如与x86一起运行的IINA,即使是首次启动,也可以像您期望的那样在一台新机器上以最快的速度运行,其中大多数机器不到5秒。非常令人印象深刻。

如果选择使用xcode提供的git,则在安装Xcode之后,您必须同意其许可

您尚未同意Xcode许可协议。您必须同意下面的两个许可协议才能使用Xcode。单击Return键可在'/Applications/Xcode.app/Contents/Resources/English.lproj/License.rtf'同意Xcode / iOS上查看许可协议许可证需要管理员权限,请运行“ sudo xcodebuild -license”,然后重试此命令。

只需使用其命令,按空格键继续并按q退出,然后键入同意同意许可。然后可以使用git,make之类的命令。

目前尚未在Apple Silicon Macs上正式支持Homebrew,并且他们的团队正在研究它。他们提供了如何支持核心公式的详细列表。您可以在此处找到该列表。

由于目前尚无此Mac的官方支持,因此下面列出的大多数安装只是我在本地计算机上测试的个人变通办法。无法保证这是最佳做法,否则将在您的计算机上正常工作。

我在homebrew的官方文档中找到了这种替代安装方法,可以在这里找到

对于基于ARM的macs,他们的建议是“帮自己一个忙,并在macOS ARM上安装到/ opt / homebrew”。最简单的方法之一是将其解压缩到本地目录,然后将其移动到/ opt它需要root权限才能写入/ opt文件夹。

cd〜mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrewsudo mv homebrew / opt / homebrew

这样,自制软件将安装到/ opt / homebrew文件夹中。然后,我们可以通过cd初始化自制程序到该目录,并在bin文件夹中运行brew。

此操作需要git,而git并未像旧版mac一样内置在ARM Big Sur中。如果您没有预先安装xcode,则会弹出另一个窗口,要求您为开发人员安装命令行工具。预期的输出(如在我的本地计算机上):

在/opt/homebrew/.git/remote中初始化为空的Git存储库:枚举对象:46,完成。远程:计数对象:100%(46/46),完成。远程:压缩对象:100%(37/37), done.remote:总计159587(增量18),已重用26(增量8),数据包重用159541接收对象:100%(159587/159587),40.85 MiB | 11.00 MiB / s,完成。解析增量:100%(118220/118220),完成。来自https://github.com/Homebrew/brew==>将homebrew / core克隆到'/ opt / homebrew / Library / Taps / homebrew / homebrew-core'...远程:枚举对象:753,完成。远程:计数对象:100%(753/753),完成。远程:压缩对象:100%(500/500),完成。远程:总计835291(增量380),已重复使用446(增量253),已重新使用包装的834538接收对象:100%(835291/835291),332.87 MiB |已完成11.64 MiB / s解析增量:已完成100%(562744/562744)使用2条命令和5344个公式(5,629个文件,365.2MB)已经是最新的。

之后,您可以将brew(以及brew管理的软件包)添加到PATH。

对于macOS Big Sur,默认外壳为zsh。您可以在主目录中创建一个.zshrc文件,并将此行添加到配置中。

Brew尚未提供可用于ARM Mac的预编译软件包。最好的安装方法是使用brew install -s 命令。如homebrew所解释,它将“即使提供了瓶也可以从源代码编译公式。如果有依赖关系,仍将从瓶中安装依赖项。”可在此处找到受支持的软件包的列表。

我已经在本地计算机上成功编译了几个二进制文件,并且将二进制文件上传为瓶子以节省一些编译时间。

autoconf gnutls libmpc luarocks sqliteautomake guile libssh2 mpfr texinfobdw-gc isl libtasn1 msgpack tree-sittercmake jansson libtermkey ncurses unboundcoreutils jpeg libtiff nettle unibiliumcurl libatomic_ops libtool [email protected] wgetexpat libpgmunigggpggggpglibfftgggpggpgzgpgpgggpggpgggpggggpgggggggggliblib中文-cms2 [email protected] libiconv lua readlinegnu-sed libidn2 luajit sphinx-doc

我遇到的问题:编译neovim时,我发现系统无法重新分配luajit安装并不断向我发送错误:在/ opt / homebrew / opt / luajit中找不到Lua解释器

我通过在/ opt / homebrew / opt / luajit / bin文件夹中创建一个符号链接来解决此问题,该链接将lua重定向到luajit,

cd / tmp / neovim-20201117-74316-1uv0si9 / build / runtime / pack / dist / opt / vimball && /opt/homebrew/Cellar/cmake/3.18.4/bin/cmake -E复制目录/ tmp / neovim-20201117- 74316-1uv0si9 / runtime / pack / dist / opt / vimball / tmp / neovim-20201117-74316-1uv0si9 / build / runtime / pack / dist / opt / vimballcd / tmp / neovim-20201117-74316-1uv0si9 / build / runtime / pack / dist / opt / matchit && /opt/homebrew/Cellar/cmake/3.18.4/bin/cmake -E copy_directory / tmp / neovim-20201117-74316-1uv0si9 / runtime / pack / dist / opt / matchit / tmp / neovim-20201117-74316-1uv0si9 / build / runtime / pack / dist / opt / matchitcd / tmp / neovim-20201117-74316-1uv0si9 / build / runtime && /opt/homebrew/Cellar/cmake/3.18.4/bin/cmake -E复制目录/ tmp / neovim-20201117-74316-1uv0si9 / runtime / doc doccd / tmp / neovim-20201117-74316-1uv0si9 / build / runtime / pack / dist / opt / vimball && / tmp / neovim-20201117-74316- 1uv0si9 / build / bin / nvim -u NONE -i NONE -e --headless -c helptags \ doc -c quitcd / tmp / neovim-20201117-74316-1uv0si9 / build / runtime / pack / dist / opt / matchit && / tmp / neovim-20201117-74316- 1uv0si9 / build / bin / nvim -u NONE -i NONE -e --headless -c helptags \ doc -c quit / bin / sh:行1:77744被杀死:9 / tmp / neovim-20201117-74316-1uv0si9 / build / bin / nvim -u NONE -i NONE -e --headless -c helptags \ doc -c quit / bin / sh:行1:77743已杀死:9 / tmp / neovim-20201117-74316-1uv0si9 / build / bin / nvim -u NONE -i NONE -e --headless -c helptags \ doc -c quitmake [2]:*** [运行时/打包/ dist / opt / matchit / doc / tags]错误137make [2]:** *等待未完成的作业。...make [2]:*** [runtime / pack / dist / opt / vimball / doc / tags]错误137cd / tmp / neovim-20201117-74316-1uv0si9 / build / runtime && / tmp / neovim-20201117-74316-1uv0si9 / build / bin / nvim -u NONE -i NONE -e --headless -c helptags \ ++ t \ doc -c quit / bin / sh:第1行:77746已杀死:9 / tmp / neovim-20201117-74316-1uv0si9 / build / bin / nvim -u NONE -i NONE -e --headless -c helptags \ ++ t \ doc -c quitmake [2]:*** [运行时/ doc / tags]错误137make [1]:*** [runtime / CMakeFiles / runtime.dir / all]错误2make:*** [all]错误2

正在检查xcrun ...正在检查xcrun ...正在检查make ...是正在检查GNU Make ...正在检查生成系统类型... arm-apple-darwin20.1.0正在检查主机系统类型... arm-apple-darwin20.1.0configure:错误:Emacs不支持'arm-apple-darwin20.1.0'系统,如果您认为应该,请发送报告至[email protected]。检查'etc / MACHINES'以获取可识别的配置名称。

但这确实帮助我测试了另外一堆软件包。具有讽刺意味的是,从GNU网站下载的emacs.app(emacsformacosx)可以正常工作,猜测我会在neovim或emacs本地构建之前坚持使用它。