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

nodejs: special node-gyp patch is only being used by npmConfigHook #385035

Open
3 tasks done
TomaSajt opened this issue Feb 25, 2025 · 0 comments
Open
3 tasks done

nodejs: special node-gyp patch is only being used by npmConfigHook #385035

TomaSajt opened this issue Feb 25, 2025 · 0 comments
Labels
0.kind: bug Something is broken

Comments

@TomaSajt
Copy link
Contributor

TomaSajt commented Feb 25, 2025

Nixpkgs version

25.05 (unstable)

Describe the bug

There is a patch used in nodejs which adds special functionality if the NIX_NODEJS_BUILDNPMPACKAGE env var is set.

See:
https://github.com/NixOS/nixpkgs/blob/b56714751a891d9b56f26550fa515bddacf7feff/pkgs/development/web/nodejs/node-npm-build-npm-package-logic.patch

This is only ever being used in npmConfigHook.
See:


I didn't know about this patch and have multiple times encountered the issue of node-gyp complaining that it doesn't have the setuptools python dependency. This was expected, since I was just using python3 (or nodejs.python).

What really surprised me was that this didn't happen before with buildNpmPackage, only with the newer yarnConfgHook and pnpm.configHook
So, like mentioned before, NIX_NODEJS_BUILDNPMPACKAGE needs to be set to trigger the special node-gyp resolution logic, but it's not being set by the other config-hooks.

You can get most of the packages that had to manually specify setuptools with this command:
rg nodejs -l | xargs rg setuptools

Steps to reproduce

Build gancio, but replace python.withPackages ... with just python.

It will fail because of node-gyp.

Now set env.NIX_NODEJS_BUILDNPMPACKAGE = "1"

It will work again.

Expected behaviour

I don't know what should be done. I'm looking for ideas. Maybe other hooks should also include this env var?

Screenshots

No response

Relevant log output

\npm verbose pkgid [email protected]
\npm error code 1
\npm error path /build/source/node_modules/sqlite3
\npm error command failed
\npm error command sh -c prebuild-install -r napi || node-gyp rebuild
\npm error prebuild-install info begin Prebuild-install version 7.1.2
npm error prebuild-install warn This package does not support N-API version undefined
npm error prebuild-install info looking for local prebuild @ prebuilds/sqlite3-v5.1.7-napi-v127-linux-x64.tar.gz
npm error prebuild-install info looking for cached prebuild @ /build/tmp.hZhD0p5K9r/.npm/_prebuilds/fb8c35-sqlite3-v5.1.7-napi-v127-linux-x64.tar.gz
npm error prebuild-install http request GET https://github.com/TryGhost/node-sqlite3/releases/download/v5.1.7/sqlite3-v5.1.7-napi-v127-linux-x64.tar.gz
npm error prebuild-install warn install getaddrinfo EAI_AGAIN github.com
npm error gyp info it worked if it ends with ok
npm error gyp verb cli [
npm error gyp verb cli   '/nix/store/7l1wra7b87yci5dln0hm0k8rwww6f2xj-nodejs-22.14.0/bin/node',
npm error gyp verb cli   '/build/source/node_modules/sqlite3/node_modules/.bin/node-gyp',
npm error gyp verb cli   'rebuild'
npm error gyp verb cli ]
npm error gyp info using [email protected]
npm error gyp info using [email protected] | linux | x64
npm error gyp verb command rebuild []
npm error gyp verb command clean []
npm error gyp verb clean removing "build" directory
npm error gyp verb command configure []
npm error gyp verb find Python Python is not set from command line or npm configuration
npm error gyp verb find Python Python is not set from environment variable PYTHON
npm error gyp verb find Python checking if "python3" can be used
npm error gyp verb find Python - executing "python3" to get executable path
npm error (node:708) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
npm error (Use `node --trace-deprecation ...` to show where the warning was created)
npm error gyp verb find Python - executable path is "/nix/store/26yi95240650jxp5dj78xzch70i1kzlz-python3-3.12.9/bin/python3"
npm error gyp verb find Python - executing "/nix/store/26yi95240650jxp5dj78xzch70i1kzlz-python3-3.12.9/bin/python3" to get version
npm error gyp verb find Python - version is "3.12.9"
npm error gyp info find Python using Python version 3.12.9 found at "/nix/store/26yi95240650jxp5dj78xzch70i1kzlz-python3-3.12.9/bin/python3"
npm error gyp verb get node dir compiling against specified --nodedir dev files: /nix/store/7l1wra7b87yci5dln0hm0k8rwww6f2xj-nodejs-22.14.0
npm error gyp verb build dir attempting to create "build" dir: /build/source/node_modules/sqlite3/build
npm error gyp verb build dir "build" dir needed to be created? Yes
npm error gyp verb build/config.gypi creating config file
npm error gyp verb build/config.gypi writing out config file: /build/source/node_modules/sqlite3/build/config.gypi
npm error gyp verb config.gypi checking for gypi file: /build/source/node_modules/sqlite3/config.gypi
npm error gyp verb common.gypi checking for gypi file: /build/source/node_modules/sqlite3/common.gypi
npm error gyp verb gyp gyp format was not specified; forcing "make"
npm error gyp info spawn /nix/store/26yi95240650jxp5dj78xzch70i1kzlz-python3-3.12.9/bin/python3
npm error gyp info spawn args [
npm error gyp info spawn args   '/build/source/node_modules/node-gyp/gyp/gyp_main.py',
npm error gyp info spawn args   'binding.gyp',
npm error gyp info spawn args   '-f',
npm error gyp info spawn args   'make',
npm error gyp info spawn args   '-I',
npm error gyp info spawn args   '/build/source/node_modules/sqlite3/build/config.gypi',
npm error gyp info spawn args   '-I',
npm error gyp info spawn args   '/build/source/node_modules/node-gyp/addon.gypi',
npm error gyp info spawn args   '-I',
npm error gyp info spawn args   '/nix/store/7l1wra7b87yci5dln0hm0k8rwww6f2xj-nodejs-22.14.0/include/node/common.gypi',
npm error gyp info spawn args   '-Dlibrary=shared_library',
npm error gyp info spawn args   '-Dvisibility=default',
npm error gyp info spawn args   '-Dnode_root_dir=/nix/store/7l1wra7b87yci5dln0hm0k8rwww6f2xj-nodejs-22.14.0',
npm error gyp info spawn args   '-Dnode_gyp_dir=/build/source/node_modules/node-gyp',
npm error gyp info spawn args   '-Dnode_lib_file=/nix/store/7l1wra7b87yci5dln0hm0k8rwww6f2xj-nodejs-22.14.0/$(Configuration)/node.lib',
npm error gyp info spawn args   '-Dmodule_root_dir=/build/source/node_modules/sqlite3',
npm error gyp info spawn args   '-Dnode_engine=v8',
npm error gyp info spawn args   '--depth=.',
npm error gyp info spawn args   '--no-parallel',
npm error gyp info spawn args   '--generator-output',
npm error gyp info spawn args   'build',
npm error gyp info spawn args   '-Goutput_dir=.'
npm error gyp info spawn args ]
npm error Traceback (most recent call last):
npm error   File "/build/source/node_modules/node-gyp/gyp/gyp_main.py", line 42, in <module>
npm error     import gyp  # noqa: E402
npm error     ^^^^^^^^^^
npm error   File "/build/source/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 9, in <module>
npm error     import gyp.input
npm error   File "/build/source/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 19, in <module>
npm error     from distutils.version import StrictVersion
npm error ModuleNotFoundError: No module named 'distutils'
npm error gyp ERR! configure error
npm error gyp ERR! stack Error: `gyp` failed with exit code: 1
npm error gyp ERR! stack     at ChildProcess.onCpExit (/build/source/node_modules/node-gyp/lib/configure.js:259:16)
npm error gyp ERR! stack     at ChildProcess.emit (node:events:518:28)
npm error gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:293:12)
npm error gyp ERR! System Linux 6.12.11
npm error gyp ERR! command "/nix/store/7l1wra7b87yci5dln0hm0k8rwww6f2xj-nodejs-22.14.0/bin/node" "/build/source/node_modules/sqlite3/node_modules/.bin/node-gyp" "rebuild"
npm error gyp ERR! cwd /build/source/node_modules/sqlite3
npm error gyp ERR! node -v v22.14.0
npm error gyp ERR! node-gyp -v v8.4.1
npm error gyp ERR! not ok

Additional context

No response

System metadata

  • system: "x86_64-linux"
  • host os: Linux 6.12.11, NixOS, 25.05 (Warbler), 25.05.20250127.f898cbf
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.24.11
  • nixpkgs: /nix/store/8711q2ng7k38b816qw6i3bp4bsl57r70-source

Notify maintainers

@winterqt

Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)

I assert that this issue is relevant for Nixpkgs

Is this issue important to you?

Add a 👍 reaction to issues you find important.

@TomaSajt TomaSajt added the 0.kind: bug Something is broken label Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

No branches or pull requests

1 participant