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

Update npm version in tests #642

Merged
merged 1 commit into from
Aug 31, 2023
Merged

Update npm version in tests #642

merged 1 commit into from
Aug 31, 2023

Conversation

brayanhenao
Copy link
Member

Context

When we updated the Python version that this Buildpack uses in #641, a new error came out on the CI. After some workaround, I found that there is an incompatibility between node-gyp and python3.11 when you are trying to build native modules using NPM <=7.

NPM is not going to fix this behavior as seen in mmomtchev/pymport#19 (an example of a native module getting errors when using npm6 and Python 3.11) because it's an old/deprecated NPM version (associated with Node 14.x, deprecated some time ago in #608)

This is fixed using NPM >=8

2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR! Traceback (most recent call last):
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!   File "/tmp/contents395280350/deps/0/node/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 51, in <module>
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!     sys.exit(gyp.script_main())
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!              ^^^^^^^^^^^^^^^^^
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!   File "/tmp/contents395280350/deps/0/node/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 670, in script_main
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!     return main(sys.argv[1:])
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!            ^^^^^^^^^^^^^^^^^^
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!   File "/tmp/contents395280350/deps/0/node/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 662, in main
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!     return gyp_main(args)
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!            ^^^^^^^^^^^^^^
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!   File "/tmp/contents395280350/deps/0/node/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 629, in gyp_main
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!     [generator, flat_list, targets, data] = Load(
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!                                             ^^^^^
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!   File "/tmp/contents395280350/deps/0/node/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 150, in Load
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!     result = gyp.input.Load(
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!              ^^^^^^^^^^^^^^^
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!   File "/tmp/contents395280350/deps/0/node/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 3021, in Load
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!     LoadTargetBuildFile(
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!   File "/tmp/contents395280350/deps/0/node/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 411, in LoadTargetBuildFile
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!     build_file_data = LoadOneBuildFile(
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!                       ^^^^^^^^^^^^^^^^^
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!   File "/tmp/contents395280350/deps/0/node/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 239, in LoadOneBuildFile
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!     build_file_contents = open(build_file_path, "rU").read()
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR!                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR! ValueError: invalid mode: 'rU' while trying to load binding.gyp
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR! gyp ERR! configure error
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/tmp/contents395280350/deps/0/node/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:514:28)
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
   2023-08-30T14:38:19.81-0400 [STG/0] OUT npm ERR! gyp ERR! System Linux 5.19.0-41-generic

Solution

Since the test is checking the behavior of Node when installing a specific version of NPM, and taking into account that the default version of the buildpack is 18.x I changed the tests to install NPM 8 (default version of 16.x) which does not present problems with the above-mentioned node-gyp behavior and follows the test purpose.

@brayanhenao brayanhenao requested a review from a team August 30, 2023 19:17
@brayanhenao brayanhenao changed the title Update npm version requested for test Update npm version in tests Aug 30, 2023
@TisVictress TisVictress merged commit 9e10528 into develop Aug 31, 2023
6 checks passed
@TisVictress TisVictress deleted the fix-npm-error branch August 31, 2023 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants