运行 PACT 测试抛出 Ruby 加载错误

Running PACT test is throwing a Ruby Load Error

我正在尝试 运行 来自 Visual Studio 代码的 typescript/angular 服务的契约测试。我收到以下错误:

ERROR (15568 ): pact-node@10.11.11: Pact Binary Error: C:/projects/App/sample.webapp/node_modules/@pact-foundation/pact-node/standalone/win32-1.88.40/pact/lib/ruby/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in
`require': cannot load such file -- bundler/setup (ERROR (15568): pact-node@10.11.11: Pact Binary Error: LoadError)
from C:/projects/App/sample.webapp/node_modules/@pact-foundation/pact-node/standalone/win32-1.88.40/pact/lib/ruby/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'       

看起来像臭名昭著的windows long path issue。有关更多详细信息,请参阅该问题,但最简单的选择是将项目目录移动到更接近 c:.

的根目录

对于上下文,Ruby 被捆绑到 Pact JS 中作为匹配、代理交互和验证逻辑的核心引擎。我们的 v3(没有这个问题)将有一个生锈的核心,你可以在这里试用测试版:https://github.com/pact-foundation/pact-js/#pact-js-v3

此问题已在 Ruby v3.0.2 中解决(请参阅此 PR https://github.com/ruby/ruby/pull/4505)。虽然贡献者不会用最新的 Ruby 版本重新打包 Pact 库,但仍然建议通过将项目目录定位在靠近根目录 c:\ 或开始使用 pact-js v3.

来解决问题