electron / rebuild

Package to rebuild native Node.js modules against the currently installed Electron version
MIT License
1.03k stars 175 forks source link

v3.2.8 breaks packaging electron app with ffi-napi dependency #1024

Open t57ser opened 2 years ago

t57ser commented 2 years ago

Following error is thrown:

An unhandled rejection has occurred inside Forge: Error: /m/i1/temp/buildTmp/electron-packager/linux-x64/test-x64/resources/app/node_modules/ffi-napi/build/node_gyp_bins/python3: file links out of the package

Using electron-forge 6.0.0-beta.64 with electron 20 beta and ffi-napi 4.0.3 Only happens on mac and linux

Once i revert back to 3.2.7 packaging the application is working again.

VerteDinde commented 2 years ago

@t57ser Can you include the module that's breaking, or a repro of the break in Electron Fiddle? We're able to build a module with ff-napi without seeing this error, just want to try and get a repro for a deeper look 👀

t57ser commented 2 years ago

@VerteDinde Here you go: https://gist.github.com/t57ser/3be2bc0d590690ece381f69e8c316edf remember this only happens on mac, not on windows

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
VerteDinde commented 2 years ago

Sorry @t57ser, could you include the Mac/Linux arch you're using, and the version of Electron 20-beta? I've been trying to repro on Mac arm64 using your gist, and I haven't been able to hit this error. We have another maintainer on Linux who was also trying to repro on Ubuntu 22.04 / Xorg (using Electron 20.0.0-b13 and electron-rebuild 3.2.8) who is also not able to repro.

Maybe this is specific to a Python version or arch? Just trying to get more details so we can try to fix this before Electron 20 stable for you 🤔

t57ser commented 2 years ago

macOS Monterey 12.4. x86_64 electron 20.0.0-beta.11 I am quite surprised you can not reproduce this since i have tried this on multiple machines I just tried a brand new mac, installed node etc... and same error

t57ser commented 2 years ago

Starting electron works, but packaging does not work, maybe that is the misunderstanding. So in my example that i send, you need to npm run package

fcastilloec commented 2 years ago

I'm having the same issue, trying to compile for electron 16. I can see the issue in Linux and macOS, I haven't tested Windows yet. Here's the output I get from a GitHub action. It's the same error I get on my local machines:

https://github.com/headsetapp/headset-electron/runs/7615723093?check_suite_focus=true

VerteDinde commented 2 years ago

Here's my terminal output when trying to reproduce on an arm64 Mac (Monterey) with both E20.0.0-beta.11 and E20.0.0-beta.13, running npm run package with Fiddle using @t57ser's gist above: output-packaging.txt

The only change between 3.2.7 and 3.2.8 is this change, which doesn't force a config rebuild when using alpha and/or beta 🤔 : https://github.com/electron/electron-rebuild/pull/1023/files I'm not sure how this is affecting the python link, and it's interesting that this seems to be happening independent of the Electron version. I'll test a x64 Mac and see if this could be an architecture difference.

fcastilloec commented 2 years ago

The only change between 3.2.7 and 3.2.8 is this change, which doesn't force a config rebuild when using alpha and/or beta thinking : https://github.com/electron/electron-rebuild/pull/1023/files I'm not sure how this is affecting the python link, and it's interesting that this seems to be happening independent of the Electron version. I'll test a x64 Mac and see if this could be an architecture difference.

That is not the only change introduce in this version, it's the only one reported on the Releases page. Here's the list of changes: https://github.com/electron/electron-rebuild/compare/v3.2.7...v3.2.8 Multiple dependencies have been upgraded, and at least two of them have been a major version change with breaking changes: detect-libc and node-gyp. Perhaps the problem is with some of those dependencies.

VerteDinde commented 2 years ago

@fcastilloec Thanks for the call-out, you're right! I think this may be the source of the issue: https://github.com/nodejs/node-gyp/commit/b9ddcd5bbd93b05b03674836b6ebdae2c2e74c8c We'll get this fixed

cclauss commented 2 years ago

Maybe this is specific to a Python version or arch?

Have never seen Python generate a file links out of the package message. Please see https://github.com/nodejs/node-gyp/issues/2713#issuecomment-1222259434

ggreco commented 2 years ago

The problem is the major version upgrade of node-gyp in a minor version, IMHO this should not permitted since it break the semantic versioning logic. A minor update should be safe.

For some reason node-gyp developer added a link to the python interpreter inside the build directory, that electron applications try to pack in the bundle, and obviously a link to the filesystem inside an application bundle is not allowed...

https://github.com/nodejs/node-gyp/issues/2713

... they have a PR for this on node-gyp, but maybe it's better to release a .10 release of electron-rebuild that fixes this as electron packager, asar and other did....

cclauss commented 2 years ago

Please provide a code review on nodejs/node-gyp#2721 to encourage maintainers to merge it.

jagthedrummer commented 1 year ago

Would love to see some sort of fix for this.

jagthedrummer commented 1 year ago

I was finally able to work around this by adding a resolutions block to my package.json that looks like this:

  "resolutions": {
    "**/**/fsevents": "^1.2.9",
    "**/**/node-gyp": "^8.4.0"
  }
Mykolaichenko commented 1 year ago

Thank you @jagthedrummer - I can confirm it works, finally fixed the issue:

An unhandled rejection has occurred inside Forge:
Error: /tmp/electron-packager/win32-ia32/Flow-win32-ia32/resources/app/node_modules/bufferutil/build/node_gyp_bins/python3: file "../../../../../../usr/bin/python3.10" links out of the package

Electron Forge was terminated. Location:
{}
error Command failed with exit code 1.