Skip to content

Insallation pact-node with pact-js fails to downloads binary in local mode #234

Closed
@jlebiannic

Description

@jlebiannic

Software versions

  • OS: Debian GNU/Linux 10 (buster)
  • Library version: 10.9.7
  • Node Version: v10.21.0

Expected behaviour

In offline mode with configuration:

  "config": {
    "pact_binary_location": "/xxx/pact"
  },

When I install pact-js 9.11.1 (which have a dependency to pact-node 10.9.7):

npm install -S @pact-foundation/pact@9.11.1

I expect pact-node download binary from "/xxx/pact" ( "pact_binary_location" )

Actual behaviour

I get this error:

Downloading Pact Standalone Binary v1.85.0 for platform linux from https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.85.0/pact-1.85.0-linux-x86_64.tar.gz
Please note: we are tracking this download anonymously to gather important usage statistics. To disable tracking, set 'pact_do_not_track: true' in your package.json 'config' section.
Error: Error while installing binary: Postinstalled Failed Unexpectedly: Error downloading binary from https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.85.0/pact-1.85.0-linux-x86_64.tar.gz: Error: Error while installing binary: Error: getaddrinfo ENOTFOUND github.com github.com:443
at throwError (/home/le-biannicj/.npm-global/lib/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/install.js:29:11)
at /home/le-biannicj/.npm-global/lib/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/install.js:311:16
at process._tickCallback (internal/process/next_tick.js:68:7)

It fails in postinstall.js file of pact-node.

Steps to reproduce

  • Mode offline with local npm repository (no access to github).

  • Js project with config :

    "config": {
    "pact_binary_location": "/xxx/pact"
    },

in package.json file.

npm install npm i -S @pact-foundation/pact@9.11.1

Detailed explanation

I try to install pact-js 9.11.1 (which have a dependency to pact-node 10.9.7):

npm install npm i -S @pact-foundation/pact@9.11.1

I get this error:

Downloading Pact Standalone Binary v1.85.0 for platform linux from https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.85.0/pact-1.85.0-linux-x86_64.tar.gz
Please note: we are tracking this download anonymously to gather important usage statistics. To disable tracking, set 'pact_do_not_track: true' in your package.json 'config' section.
Error: Error while installing binary: Postinstalled Failed Unexpectedly: Error downloading binary from https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.85.0/pact-1.85.0-linux-x86_64.tar.gz: Error: Error while installing binary: Error: getaddrinfo ENOTFOUND github.com github.com:443
at throwError (/home/le-biannicj/.npm-global/lib/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/install.js:29:11)
at /home/le-biannicj/.npm-global/lib/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/install.js:311:16
at process._tickCallback (internal/process/next_tick.js:68:7)

It fails in postinstall.js file of pact-node.

My CI is offline so I can't download from github so I put special configuration in my package.json file (https://github.com/pact-foundation/pact-node#pact-download-location):


  "config": {

    "pact_binary_location": "/xxx/pact"

  },

`


When I install pact-node directly it's working with the special configuration above (npm install @pact-foundation/pact-node@10.9.7).

I took a look at **standalone/install.ts** file in pact-node (which is called by **postinstall.js**) and I saw this code:
`
export function createConfig(): Config {

	const packageConfig = findPackageConfig(path.resolve(__dirname, '..', '..'));

...

This code goes back from two directory in order to find the package.json file of the owner project.

I think when I install pact-js which depends of pact-node, the function "findPackageConfig" find the package.json of pact-js (which have no special configuration "pact_binary_location") and not mine so it try to download from github and fails (because i can't download from github).

Exemple of project hierachy:

<my-project>

	...

	package.json (with conf: ... "pact_binary_location": "/xxx/pact")

	node_modules

		<pact-js>

		   ...

		   package.json (no conf pact_binary_location)

		   node_modules

			<pact-node>

			    package.json

                            standalone

				install.ts

In this example of hierarchy, when the code of pact-node (standalone/install.ts):
findPackageConfig(path.resolve(__dirname, '..', '..'));
is executed, i think it find the package.json of pact-js and not mine (with conf: ... "pact_binary_location": "/xxx/pact")

I have missing something ?
I there a way to tell pact-node to take my package.json with the configuration for "pact_binary_location" ?
Regards

Activity

TimothyJones

TimothyJones commented on Aug 3, 2020

@TimothyJones
Contributor

Thanks for the report! Looks like we have indeed made a mistake in the way we read package.json. I'll look at a fix as soon as I can.

I believe as a workaround you can install the relevant version of pact-node directly as a dependency of your project. Does that work for you?

jlebiannic

jlebiannic commented on Sep 4, 2020

@jlebiannic
Author

Thanks for the report! Looks like we have indeed made a mistake in the way we read package.json. I'll look at a fix as soon as I can.

I believe as a workaround you can install the relevant version of pact-node directly as a dependency of your project. Does that work for you?

sorry I was on vacation and didn't take the time to answer :)
I would like to install pack-js and since it depends on pact-node I am stuck due to the error explained above.

TimothyJones

TimothyJones commented on Sep 4, 2020

@TimothyJones
Contributor

For now, I think the workaround (to have your project directly depend on @pact-foundation/pact-node as well as @pact-foundation/pact) should unblock you. Can you confirm if this works?

mefellows

mefellows commented on Sep 5, 2020

@mefellows
Member

Thanks for the report btw (I've just updated the report to make the errors clearer).

jlebiannic

jlebiannic commented on Sep 8, 2020

@jlebiannic
Author

For now, I think the workaround (to have your project directly depend on @pact-foundation/pact-node as well as @pact-foundation/pact) should unblock you. Can you confirm if this works?

Yes i confirm it works if i add pact-node in my package.json so i m unblocked :)

TimothyJones

TimothyJones commented on Feb 9, 2021

@TimothyJones
Contributor

This should be fixed in v10.11.8, which is building as I write this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @mefellows@TimothyJones@jlebiannic

        Issue actions

          Insallation pact-node with pact-js fails to downloads binary in local mode · Issue #234 · pact-foundation/pact-js-core