GitHub
04/27/2024, 4:37 PMFailed to load native module. The problem is similar to #472, but this one is for linux-x64 (redhat ubi8 minimal).
Steps to reproduce
Repo: https://github.com/praveen-em/pact-consumer-js.git (this example is based on the one used in pact js workshop)
This problem occurred initially while trying to run pact tests on Jenkins agents (pods) running on ocp (Openshift Container Platform). Those pods use redhat ubi8 minimal base image. See steps below to recreate the problem locally.
1. git clone <https://github.com/praveen-em/pact-consumer-js.git>
2. docker buildx build --platform linux/amd64 -t pactdemo:amd . --> This will create image pactdemo:amd
3. docker run --platform linux/amd64 pactdemo:amd --> using the image created in the previous step
Relevant log files
> pact-consumer-js@0.1.0 test
> cross-env LOG_LEVEL=trace CI=true react-scripts test
PASS src/api.spec.js
[16:15:19.990] DEBUG (101): pact-core@14.3.4: We detected your platform as:
- linux-x64
FAIL src/api.pact.spec.js
● Test suite failed to run
Failed to load native module, try setting LOG_LEVEL=debug for more info
8 | const { eachLike, like } = MatchersV3;
9 |
> 10 | const provider = new PactV3({
| ^
11 | consumer: "FrontendWebsite",
12 | provider: "ProductService",
13 | log: path.resolve(process.cwd(), "logs", "pact.log"),
at initialiseFfi (node_modules/@pact-foundation/pact-core/src/ffi/index.ts:113:11)
at getFfiLib (node_modules/@pact-foundation/pact-core/src/ffi/index.ts:125:11)
at makeConsumerPact (node_modules/@pact-foundation/pact-core/src/consumer/index.ts:67:24)
at PactV3.Object.<anonymous>.PactV3.setup (node_modules/@pact-foundation/src/v3/pact.ts:250:33)
at new PactV3 (node_modules/@pact-foundation/src/v3/pact.ts:49:10)
at Object.<anonymous> (src/api.pact.spec.js:10:18)
[16:15:20.379] TRACE (101): pact-core@14.3.4: Initiliasing ffi for the first time
[16:15:20.381] DEBUG (101): pact-core@14.3.4: Initalising native core at log level 'warn'
[16:15:20.381] DEBUG (101): pact-core@14.3.4: binding path #0: : attempting to load native module from:
- /app/node_modules/@pact-foundation/pact-core/prebuilds/linux-x64
source: pact-js-core binding lookup
- You can override via PACT_PREBUILD_LOCATION
[16:15:20.387] DEBUG (101): pact-core@14.3.4: binding path #1: : attempting to load native module from:
- /app/prebuilds/linux-x64
source: pact-js-core binding lookup
- You can override via PACT_PREBUILD_LOCATION
[16:15:20.391] DEBUG (101): pact-core@14.3.4: Supported platforms are:
- darwin-arm64
- darwin-x64
- linux-arm64
- linux-x64
- win32-x64
[16:15:20.392] ERROR (101): pact-core@14.3.4: Failed to find native module for linux-x64: TypeError: Cannot read properties of undefined (reading 'pactffiInitWithLogLevel')
[16:15:20.392] DEBUG (101): pact-core@14.3.4: We looked for a supported build in this location /app/node_modules/@pact-foundation/pact-core/prebuilds/linux-x64
[16:15:20.394] DEBUG (101): pact-core@14.3.4: We looked for a supported build in this location /app/prebuilds/linux-x64
[16:15:20.394] DEBUG (101): pact-core@14.3.4: Tip: check there is a prebuild for linux-x64
check the path exists
Wrong Path?: set the load path with PACT_PREBUILD_LOCATION ensuring that $PACT_PREBUILD_LOCATION/prebuilds/linux-x64 exists
- Note: You dont need to include the prebuilds/linux-x64 part of the path, just the parent directory
- Let us know: We can add more supported path lookups easily, chat to us on slack or raise an issue on github
Test Suites: 1 failed, 1 passed, 2 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Time: 3.57 s
Ran all test suites.
pact-foundation/pact-js-coreGitHub
04/29/2024, 11:25 PMGitHub
04/30/2024, 2:02 AMGitHub
05/13/2024, 12:39 PM