Truffle 无法在 Mac M1 上安装

Sim*_*mon 3 truffle consensys-truffle

我正在尝试在我的 mac M1 上安装 Truffle。

我首先按照 Pet Shop 教程中 truffle 网站上的说明操作,成功安装了节点,但随后出现此错误...

sudo npm install -g truffle
...
npm ERR! 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)).
Run Code Online (Sandbox Code Playgroud)

我做了一些研究,并被指出在自制软件中尝试它。由于我的 M1 芯片,我必须先更新自制程序,我成功地做到了。但我仍然得到看似相同或相似的错误......

/opt/homebrew/bin/brew install truffle
...
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)).
truffle: The x86_64 architecture is required for this software.
Run Code Online (Sandbox Code Playgroud)

我在网上找不到太多关于这个的信息。

这是否意味着松露只能在英特尔芯片上运行,而我需要使用像罗塞塔这样的东西?

Sim*_*mon 6

好的,所以我终于弄清楚了这一点,并想我将在这里发布给后代。

问题是我在 M1 Mac 上安装的 xcode 命令行工具的版本。我不知道如何,但它是一个过时的版本。修复方法是删除命令行工具并重新安装它们。我认为(我不能肯定地说)这用 M1/Arm 版本替换了它们,然后所需的编译工具就位了。

要更新,我按照苹果开发者论坛帖子中的步骤进行操作 https://developer.apple.com/forums/thread/694283

基本上...

删除现有文件夹

sudo rm -rf /Library/Developer/CommandLineTools
Run Code Online (Sandbox Code Playgroud)

重新安装

sudo Xcode-select --install 
Run Code Online (Sandbox Code Playgroud)

这样做之后我重新运行

sudo npm install -g truffle
Run Code Online (Sandbox Code Playgroud)

它成功完成(尽管有一堆审计警告)