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

Pact JS v12.1.0 can not be installed #1136

Closed
Jan429vv opened this issue Nov 10, 2023 · 12 comments
Closed

Pact JS v12.1.0 can not be installed #1136

Jan429vv opened this issue Nov 10, 2023 · 12 comments
Labels
awaiting feedback Awaiting Feedback from OP bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer

Comments

@Jan429vv
Copy link

Hi! I think I found a bug that occurs during the installation-process from pact-js v12.1.0

Software versions

Please provide at least OS and version of pact-js

  • OS: Windows 10 pro 22H2
  • Consumer Pact library: Pact JS v12.1.0
  • Provider Pact library: _e.g. Pact JS v12.1.0
  • Node Version: v18.16.0

Issue Checklist

Please confirm the following:

  • [x ] I have upgraded to the latest
  • [x ] I have the read the FAQs in the Readme
  • [ x] I have triple checked, that there are no unhandled promises in my code and have read the section on intermittent test failures
  • [x ] I have set my log level to debug and attached a log file showing the complete request/response cycle
  • [x ] For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem

Expected behaviour

After typing the command npm i -S @pact-foundation/pact@latest, the dependency should be installed successfully.

Actual behaviour

The installaltion failed even though I installed Visual Studio to have an C++ Compiler (which shouldn't be necessary when using pact-js v12+). Without installing Visual Studio, the error logs say, that Visual Studio is missing, after installing Visual Studio the installation still fails with the error-message: "binding.gyp not found (cwd: C:\Users\john.doe\AppData\Local\Temp_pact\node_modules@pact-foundation\pact\node_modules@pact-foundation\pact-core) while trying to load binding.gyp"

Steps to reproduce

How can someone else reproduce this bug?

  1. Create an empty folder on your local pc.
  2. Open Visual Studio Code in this empty folder
  3. Run npm init to create a package.json
  4. Run npm i -S @pact-foundation/pact@latest

Like I already described, the installation process fails, if you Visual Studio installed or not, but the error message differs. For me it looks like, the prebuild binaries for C++ libraries are not shared like promised in the documentation and the binding.gyp file is missing, but I am not to shure what exactly is the problem. I would appreciate any help because I would like to use pact-js to write some contract-tests.

For formal reasons I created an Repository, but it has nothing in it except an empty package.json:
https://github.com/Jan429vv/pact-js-bug

Relevant log files

2023-11-10T11_25_27_534Z-debug-0.log

Thanks in advance!

@Jan429vv Jan429vv added bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer labels Nov 10, 2023
@YOU54F
Copy link
Member

YOU54F commented Nov 10, 2023

That is unexpected, as Pact-core contains the windows pre-build, you can see it in the code tab there

Screenshot 2023-11-10 at 11 57 13

They should be in

C:\Users\john.doe\AppData\Local\Temp_pact\node_modules@pact-foundation\pact\node_modules@pact-foundation\pact-core\prebuilds\

The installaltion failed even though I installed Visual Studio to have an C++ Compiler (which shouldn't be necessary when using pact-js v12+)

Yeah you shouldn't need vs studio compiler for installer, but may need it for other windows related devving.

How come you are opening vs studio in the newly created folder, prior to doing npm init

  1. Create an empty folder on your local pc.
  2. Open Visual Studio Code in this empty folder
  3. Run npm init to create a package.json
  4. Run npm i -S @pact-foundation/pact@latest

@YOU54F
Copy link
Member

YOU54F commented Nov 10, 2023

Screenshot 2023-11-10 122551

Screenshot 2023-11-10 122533

@Jan429vv
Copy link
Author

Okay, thats weird, I tried it on two different PCs, and it didn't work without Visual Studio

That is unexpected, as Pact-core contains the windows pre-build, you can see it in the code tab there

Screenshot 2023-11-10 at 11 57 13

They should be in

C:\Users\john.doe\AppData\Local\Temp_pact\node_modules@pact-foundation\pact\node_modules@pact-foundation\pact-core\prebuilds\

Yeah you shouldn't need vs studio compiler for installer, but may need it for other windows related devving.

I wanted to make sure, that it doesn't fail because of other dependencies or configurations in my project, so I created an empty folder as a test-project.

How come you are opening vs studio in the newly created folder, prior to doing npm init

@Jan429vv
Copy link
Author

Screenshot 2023-11-10 122551

Screenshot 2023-11-10 122533

Okay, very strange that it works on your machine. Is there anything that I could have missed that leads to this failure? Which version of Windows and npm do you use?

@YOU54F
Copy link
Member

YOU54F commented Nov 10, 2023

Details below - I do have vs installed on this machine, as I test lots of different languages and it was required for various things.

npm:- 9.6.7
node: v20.3.0

Edition Windows 11 Pro
Version 22H2
Installed on ‎03/‎01/‎2023
OS build 22621.2428
Experience Windows Feature Experience Pack 1000.22674.1000.0

Screenshot 2023-11-10 124431

Are you suggesting that from your experience, it only works with visual studio installed?

This is plausible, that vs is no longer needed for producing the binaries, but may be needed for something else in the installation process.

I'll test in a vanilla VM pre and post installing vs, and confirm

@YOU54F
Copy link
Member

YOU54F commented Nov 10, 2023

Is there anything that I could have missed that leads to this failure?

Not that I can see, although its making me wonder about the advise post the pre build.

I think the tools may be required, as we rely on the ffi loading capabilities of node

https://github.com/felixrieseberg/windows-build-tools?tab=readme-ov-file#examples-of-modules-supported

To ensure that that's true, we take a fresh Windows 10 installation, add windows-build-tools, and ensure that the most popular native Node addons compile from source. Those are: node-sass, bcrypt, sqlite3, serialport, websocket, deasync, grpc, canvas, sharp, hiredis, leveldown, nodegit, zqm, ffi, libxmljs, iconv, ref, sleep, microtime, couchbase, bignum, kerberos, and ursa.

However the linked package is no longer required to be installed via npm, it states at the top of the repo

Please note that the official Node.js for Windows installer can now automatically install the required tools. That's likely a much better option than the module listed here (windows-build-tools).

@YOU54F
Copy link
Member

YOU54F commented Nov 10, 2023

Just taken a look at the log files. could you try with --ignore-scripts in your npm install command please?

https://docs.npmjs.com/cli/v10/commands/npm-install#ignore-scripts

in line 1042 of the log it is performing a node-gyp rebuild, which I wouldn't have expected. the ignore-scripts option should suppress that hopefully

@Jan429vv
Copy link
Author

Just taken a look at the log files. could you try with --ignore-scripts in your npm install command please?

https://docs.npmjs.com/cli/v10/commands/npm-install#ignore-scripts

in line 1042 of the log it is performing a node-gyp rebuild, which I wouldn't have expected. the ignore-scripts option should suppress that hopefully

Yes, I had to do npm i -D @pact-foundation/pact --ignore-scripts to fix it.
Thank you!

@YOU54F
Copy link
Member

YOU54F commented Nov 10, 2023

my pleasure, glad that sorted it for you

@Jan429vv
Copy link
Author

Jan429vv commented Dec 8, 2023

Just taken a look at the log files. could you try with --ignore-scripts in your npm install command please?

https://docs.npmjs.com/cli/v10/commands/npm-install#ignore-scripts

in line 1042 of the log it is performing a node-gyp rebuild, which I wouldn't have expected. the ignore-scripts option should suppress that hopefully

Hi!

Thanks again for your help, but currently I am a bit stuck on this issue. Even though it is possible to install the pact-js dependency using the --ignore-scripts option, this isn't a permanent solution for my project. The problem is, that I am working on an Repository together with multiple devs, and since the issue occured, everybody is forced to use the --ignore-scripts option when running npm install after any new added dependency. This may have several side-effects that I can't predict and that I don't want to risk since our project is running in production. I know there may be some work-arounds but I would like to ask if pact is planning on fixing this issue, so that we don't have to use the --ignore-scripts option.

@mefellows
Copy link
Member

So it seems like for some reason it's not detecting the prebuilds exist. It's a bit tricky, because we can't reproduce the problem - if there was a way to replicate your environment/setup that would help, but perhaps another approach would be to create a github build and alter its environment somehow (e.g. removing binaries/system libs from the path).

Another option, probably the easiest for you, is to fork pact-js-core which is where the node gyp requirement comes in. If you can modify the way its used there until a point that it works for you reliably, that might give us a hint.

@mefellows mefellows added the awaiting feedback Awaiting Feedback from OP label Dec 9, 2023
@mefellows
Copy link
Member

Closing due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting feedback Awaiting Feedback from OP bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants