Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jlebiannic opened this issue Jul 31, 2020 · 6 comments
Closed
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@jlebiannic
Copy link

jlebiannic commented Jul 31, 2020

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

@TimothyJones
Copy link
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?

@TimothyJones TimothyJones added bug Indicates an unexpected problem or unintended behavior good-first-issue labels Aug 3, 2020
@jlebiannic
Copy link
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
Copy link
Contributor

TimothyJones commented Sep 4, 2020

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
Copy link
Member

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

@jlebiannic
Copy link
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
Copy link
Contributor

TimothyJones commented Feb 9, 2021

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
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants