<#502 pact-core@14.3.4: Failed to load native modu...
# pact-js-development
g
#502 pact-core@14.3.4: Failed to load native module in Linux-x64 platform (redhat ubi8 minimal) Issue created by praveen-em Software versions • OS Image: redhat ubi8 minimal • Pact Node version: 12.4.0 • Node Version: 18.19.1 • Other Versions: Running `cat /etc/os-release`: NAME="Red Hat Enterprise Linux" VERSION="8.9 (Ootpa)" ID="rhel" ID_LIKE="fedora" VERSION_ID="8.9" PLATFORM_ID="platform:el8" PRETTY_NAME="Red Hat Enterprise Linux 8.9 (Ootpa)" ANSI_COLOR="0;31" CPE_NAME="cpe/oredhatenterprise linux8::baseos" HOME_URL="https://www.redhat.com/" DOCUMENTATION_URL="https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8" BUG_REPORT_URL="https://bugzilla.redhat.com/" REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8" REDHAT_BUGZILLA_PRODUCT_VERSION=8.9 REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux" REDHAT_SUPPORT_PRODUCT_VERSION="8.9" Issue Checklist Please confirm the following: ☑︎ I have upgraded to the latest ☑︎ I have the read the FAQs in the Readme ☑︎ I have triple checked, that there are no unhandled promises in my code ☑︎ I have set my log level to debug and attached a log file showing the complete request/response cycle ☑︎ For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem Expected behaviour Pact tests should run successfully. Actual behaviour Pact tests fail with error
Failed 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
Copy code
> 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-core