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

farmhash should take an explicit dev dependency on node-gyp #47

Closed
CodingDoug opened this issue Apr 16, 2024 · 2 comments
Closed

farmhash should take an explicit dev dependency on node-gyp #47

CodingDoug opened this issue Apr 16, 2024 · 2 comments

Comments

@CodingDoug
Copy link

In package.json, you can see that it runs node-gyp as part of the install script, but does nothing to ensure that the right version of it is being used.

I have a project where I tried to add farmhash indirectly through another module. farmhash failed to build with a node-gyp error, which I have redacted a bit below to hide directory names:

npm ERR! code 1
npm ERR! path /project/node_modules/farmhash
npm ERR! command failed
npm ERR! command sh -c prebuild-install || node-gyp rebuild
npm ERR! prebuild-install warn install No prebuilt binaries found (target=3 runtime=napi arch=arm64 libc= platform=darwin)
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp info find Python using Python version 3.12.3 found at "/opt/homebrew/opt/[email protected]/bin/python3.12"
npm ERR! gyp info spawn /opt/homebrew/opt/[email protected]/bin/python3.12
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/project/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/project/node_modules/farmhash/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/project/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '$HOME/Library/Caches/node-gyp/20.12.2/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=$HOME/Library/Caches/node-gyp/20.12.2',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/project/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=$HOME/Library/Caches/node-gyp/20.12.2/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/project/node_modules/farmhash',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! Traceback (most recent call last):
npm ERR!   File "/project/node_modules/node-gyp/gyp/gyp_main.py", line 42, in <module>
npm ERR!     import gyp  # noqa: E402
npm ERR!     ^^^^^^^^^^
npm ERR!   File "/project/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 9, in <module>
npm ERR!     import gyp.input
npm ERR!   File "/project/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 19, in <module>
npm ERR!     from distutils.version import StrictVersion
npm ERR! ModuleNotFoundError: No module named 'distutils'
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/project/node_modules/node-gyp/lib/configure.js:325:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:518:28)
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:294:12)
npm ERR! gyp ERR! System Darwin 23.4.0
npm ERR! gyp ERR! command "$HOME/.nvm/versions/node/v20.12.2/bin/node" "/project/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /project/node_modules/farmhash
npm ERR! gyp ERR! node -v v20.12.2
npm ERR! gyp ERR! node-gyp -v v9.4.1
npm ERR! gyp ERR! not ok

The root problem here is that farmhash found an existing node-gyp version 9.4.1 that came from another module in the project (instead of finding the "default" one that comes with npm when installed globally).

This can be fixed if farmhash takes it own dev dependency on node-gyp 10.

@lovell
Copy link
Owner

lovell commented Apr 17, 2024

npm ERR! prebuild-install warn install No prebuilt binaries found (target=3 runtime=napi arch=arm64 libc= platform=darwin)

This relates to #41 specifically #41 (comment):

A better solution would be to provide prebuilt binaries for ARM64 macOS.

I notice Google just added farmhash as a dependency of firebase-admin, a package that has ~1 million downloads/week, so I guess my hand has been forced to address this.

Let's track at the existing #41

@lovell lovell closed this as completed Apr 17, 2024
@CodingDoug
Copy link
Author

I notice Google just added farmhash as a dependency of firebase-admin, a package that has ~1 million downloads/week, so I guess my hand has been forced to address this.

That is exactly what got me here. :)

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

No branches or pull requests

2 participants