macOS 和 dyld:找不到符号:_usdt_create_provider

macOS & dyld: Symbol not found: _usdt_create_provider

简而言之,我无法在我的开发计算机上安装@pact-foundation/pact-node,据我所知,这似乎与在 macOS 10.14 上的安装有松散的关系。当我松散地说时,这不会影响我的另一台非开发计算机 运行 相同的堆栈。

在 nvm 中,我尝试使用 Node 8.14.0、8.15.0、9.4.0、10.14.2、10.15.0 和 11.6.0,此外系统 Node 也是 11.6.0。每个版本都会产生相同的错误消息,无论我是在我团队的项目目录中还是在其他空的沙箱目录中。

直到几分钟前,我还在 运行 macOS 10.14.1 上,我在 10.14.2 上看到了同样的问题。没有未安装的更新。

包安装输出如下

$ npm install @pact-foundation/pact-node

> dtrace-provider@0.8.7 install /Users/andrewgould/www/sandbox/node_modules/dtrace-provider
> node-gyp rebuild || node suppress-error.js

  ACTION binding_gyp_ndtp_target_build_ndtp .
  TOUCH Release/obj.target/ndtp.stamp

> spawn-sync@1.0.15 postinstall /Users/andrewgould/www/sandbox/node_modules/spawn-sync
> node postinstall


> caporal@0.10.0 postinstall /Users/andrewgould/www/sandbox/node_modules/caporal
> (test -f ./node_modules/husky/bin/install.js && node ./node_modules/husky/bin/install.js) || exit 0


> @pact-foundation/pact-node@6.20.0 postinstall /Users/andrewgould/www/sandbox/node_modules/@pact-foundation/pact-node
> node postinstall.js

dyld: lazy symbol binding failed: Symbol not found: _usdt_create_provider
  Referenced from: /Users/andrewgould/www/sandbox/node_modules/dtrace-provider/src/build/Release/DTraceProviderBindings.node
  Expected in: flat namespace

dyld: Symbol not found: _usdt_create_provider
  Referenced from: /Users/andrewgould/www/sandbox/node_modules/dtrace-provider/src/build/Release/DTraceProviderBindings.node
  Expected in: flat namespace

Abort trap: 6

有没有人见过这样的错误?有已知的解决方案吗?

原来这个问题是由我通过 Homebrew 安装的 binutils 引起的。卸载解决了问题。

来自 GNU binutils 网站,其中包含的主要包是 ld,GNU 链接器和 as,GNU 汇编器。这两个工具都包含在 macOS 中,但是这些工具的 Homebrew 版本导致了上述问题中显示的冲突。