pact-foundation / pact-js

JS version of Pact. Pact is a contract testing framework for HTTP APIs and non-HTTP asynchronous messaging systems.
https://pact.io
Other
1.62k stars 344 forks source link

Issue getting @pact-foundation/pact module to even load #1044

Closed alilland closed 1 year ago

alilland commented 1 year ago

Fresh install of @pact-foundation/pact results in pact not running

$ jest tests/pact/ --runInBand
 FAIL  tests/pact/consumers/test.spec.js
  ● Test suite failed to run

    dlopen(/Users/aronlilland/Documents/dev/controlair/backbone-ui/applications/backbone/node_modules/@pact-foundation/pact-core/build/Release/pact.node, 0x0001): Library not loaded: @rpath/libpact_ffi.dylib
      Referenced from: <F1F75702-EE69-3F3A-A4D9-D477A43B6585> /Users/aronlilland/Documents/dev/controlair/backbone-ui/applications/backbone/node_modules/@pact-foundation/pact-core/build/Release/pact.node
      Reason: tried: '/Users/aronlilland/Documents/dev/controlair/backbone-ui/applications/backbone/node_modules/@pact-foundation/pact-core/build/Release/libpact_ffi.dylib' (no such file), '/Users/aronlilland/Documents/dev/controlair/backbone-ui/applications/backbone/node_modules/@pact-foundation/pact-core/build/Release/libpact_ffi.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS@rpath/libpact_ffi.dylib' (no such file), '/Users/aronlilland/Documents/dev/controlair/backbone-ui/applications/backbone/node_modules/@pact-foundation/pact-core/build/Release/libpact_ffi.dylib' (no such file), '/Users/aronlilland/Documents/dev/controlair/backbone-ui/applications/backbone/node_modules/@pact-foundation/pact-core/build/Release/libpact_ffi.dylib' (no such file), '/usr/local/lib/libpact_ffi.dylib' (no such file), '/usr/lib/libpact_ffi.dylib' (no such file, not in dyld cache)

      at Runtime._loadModule (node_modules/jest-runtime/build/index.js:1180:29)
      at bindings (node_modules/bindings/bindings.js:112:48)
      at Object.<anonymous> (node_modules/@pact-foundation/pact-core/src/ffi/index.ts:6:21)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.773 s
Ran all test suites matching /tests\/pact\//i.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Software versions

Issue Checklist

Please confirm the following:

Expected behaviour

the library wont load, this is the entire test file from referenced above, i gutted it just to see if the module will load and it wont, tried es5 and es6

import pact from '@pact-foundation/pact'

describe('The Dog API', () => {
  describe('get /dogs using builder pattern', () => {
    it('succeeds', () => {
      // Add expected interactions
    })
  })
})

Actual behaviour

the library wont load

mefellows commented 1 year ago

TIL that Ventura is the latest Mac OSX distribution!

Is it an M1 or intel setup?

So it's hard to tell from here why it's failing, but one of the following is plausible

  1. It's to do with Ventura (one hypothesis is that it is looking for the wrong ffi lib because our OS/Arch detection isn't clever enough)
  2. It's to do with yarn (I believe yarn workspaces/v2 can be an issue)
  3. ...something else

Are you able to reproduce this issue on a brand new, vanilla JS project with node? We can then step by step through the issues from there.

TimothyJones commented 1 year ago

Can you do npm ls @pact-foundation/pact-core and share the output?

Also, if you remove node_modules, then do npm install, do you see any errors?

mefellows commented 1 year ago

Closing due to inactivity.