Pact-js: "cannot load such file" error in pact-node-verifier on Windows

Created on 27 Oct 2018  Â·  6Comments  Â·  Source: pact-foundation/pact-js

I'm trying to set up provider verification for a node express server.

This is the script I'm using to start the verification:

const { Verifier } = require('@pact-foundation/pact');
const packageJson = require('../package.json');

let opts = {
    providerBaseUrl: 'http://localhost:3000',
    provider: 'hero-provider',
    pactBrokerUrl: '...',
    pactBrokerUsername: process.env.PACT_USERNAME,
    pactBrokerPassword: process.env.PACT_PASSWORD,
    publishVerificationResult: true,
    providerVersion: packageJson.version,
    timeout: 5000
};

new Verifier().verifyProvider(opts).then(function () {
    console.log("verified");
});

Once verifyProvider() is called, I get some output that Pact is connecting to my Pact Broker and then I get this error:

...\node_modules\@pact-foundation\pact-node\standalone\install.js:263
    throw new Error(chalk.red("Unhandled Promise Rejection: " + e));
    ^

Error: Unhandled Promise Rejection: Error: C:/daten/workspaces/code-examples2/pact/pact-node-provider/node_modules/@pact-foundation/pact-node/standalone/win32-1.61.1/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.20.0/lib/pact/provider_verifier/app.rb:3:in `require': cannot load such file -- pact/provider_verifier/provider_states/remove_provider_states_header_middleware (LoadError)

The cause for this error is that the Ruby implementation of the pact-provider-verifier in my node_modules folder cannot load the file pact/provider_verifier/provider_states/remove_provider_states_header_middleware in a require declaration (app.rb line 3).

However, I checked the file and it exists.

Any clues about this behavior?

Awaiting feedback Triage

Most helpful comment

The first problem relates to an as-yet-undocumented issue relating to pact-node swallowing all promises (i.e. where the stack trace seems to originate, is actually not true).

My guess is you're running into file length issues (C:/daten/workspaces/code-examples2/pact/pact-node-provider/node_modules/@pact-foundation/pact-node/standalone/win32-1.61.1/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.20.0/lib/pact/provider_verifier/provider_states/remove_provider_states_header_middleware.rb is > 255 characters (see https://github.com/pact-foundation/pact-node/issues/100 and https://github.com/pact-foundation/pact-node/issues/101)

See if you can flatten the tree and if you still run into issues then we'll have to dig further.

There is also a way you can update the registry to allow longer path lengths it seems.

All 6 comments

The first problem relates to an as-yet-undocumented issue relating to pact-node swallowing all promises (i.e. where the stack trace seems to originate, is actually not true).

My guess is you're running into file length issues (C:/daten/workspaces/code-examples2/pact/pact-node-provider/node_modules/@pact-foundation/pact-node/standalone/win32-1.61.1/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.20.0/lib/pact/provider_verifier/provider_states/remove_provider_states_header_middleware.rb is > 255 characters (see https://github.com/pact-foundation/pact-node/issues/100 and https://github.com/pact-foundation/pact-node/issues/101)

See if you can flatten the tree and if you still run into issues then we'll have to dig further.

There is also a way you can update the registry to allow longer path lengths it seems.

Yes, that was it, thanks.

The Windows registry hack hasn't worked for me, though, so I had to move the project to a shallower path.

:(

I'm really sorry, but also, Windows ¯_(ツ)_/¯

yeah, people keep telling me that... ;)

I had the same issue on macOS Catalina, the shallower path has helped me! Thanks @mefellows

I had the same issue on macOS Catalina, the shallower path has helped me! Thanks @mefellows

What! That doesn't sound right to me, and may be a symptom of another problem. But, ... glad it worked :P

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kneczaj picture kneczaj  Â·  5Comments

eauc picture eauc  Â·  6Comments

bethesque picture bethesque  Â·  9Comments

McKratt picture McKratt  Â·  3Comments

BenSayers picture BenSayers  Â·  8Comments