node-gyp: `node_gyp_bins` causes build failures in downstream packages

  • Node Version: Node 16.13.0 and NPM 8.1.0
  • Node-Gyp Version: >= v9.0.0
  • Platform: Mac & Linux
  • Module: electron-packager & electron-rebuild

Hey folks! I’m a maintainer of electron-packager and electron-rebuild. We’re seeing an issue with rebuilding native modules using node-gyp, that we think we introduced by this change: https://github.com/nodejs/node-gyp/commit/b9ddcd5bbd93b05b03674836b6ebdae2c2e74c8c .

When trying to rebuild a native module using Electron and node-gyp 9.0.0+, rebuilding will fail for older versions of python or folks using a python version manager with this error:

An unhandled rejection has occurred inside Forge:
Error: /var/folders/sp/141453k53mg70282wr9vkn_h0000gp/T/electron-packager/darwin-x64/test-darwin-x64/Electron.app/Contents/Resources/app/node_modules/ffi-napi/build/node_gyp_bins/python3:
file links out of the package

The link to the specific issue, with more details, is here: https://github.com/electron/electron-rebuild/issues/1024

We can handle this error inside electron-packager by ignoring the directory, but would it be possible to move this symlink directory outside of node_modules and into something like a tmp dir?

I wasn’t sure if the directory being in node_modules may cause other issues with other downstream users/packages, and thought we’d err on the side of reporting it 🙂 If there’s a technical reason why it needs to be included in node_modules, please feel free to close this.

Thanks for your time!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 15
  • Comments: 18 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks for looking at this. This issue also causes some impressive side-effects when using electron-forge and osx codesign. Because node-gyp leaves behind symlinks to python3, electron-builder will use osx codesign to sign the python binary while processing the app, breaking your system python install (because of resulting sig mismatch).

I am wiping node_gyp_bins manually in a build/package hook as a workaround for now, but would be great to get this resolved properly.

I know not all maintainers like this

I have never seen that. If they want to turn off the code review capability for non-maintainers then they are free to do so.

When you want a pull request to be merged, please give it a positive review as @DeeDeeG has done at the top right of this page. Every checkmark ✔️ that project maintainers see there gives them confidence that the proposed changes have been looked at and have been deemed both useful and safe to merge into the codebase. Lots of “what is the ETA?” comments are easier for maintainers to ignore than ✔️✔️✔️✔️✔️ from several different reviewers.

Anyone can review a pull request on GitHub. To do so here:

  1. Scroll to the top of the pull request page.
  2. Click the Files changed tab.
  3. Click the Review changes button.
  4. Click Approve (or one of the other options) and make comments only if they have not already been stated in the PR.
  5. Click Submit review so that your ✔️ can be added to the list.

Ok, great, I’ll do that now

I would recommend reading thru https://github.com/txoof/codesign (which is written in Python) and then opening an issue on that repo if you still do not have a resolution.