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

Cross platform prebuild #37

Open
fishbone1 opened this issue Oct 22, 2020 · 4 comments
Open

Cross platform prebuild #37

fishbone1 opened this issue Oct 22, 2020 · 4 comments

Comments

@fishbone1
Copy link

My Electron project's target platform is Windows x64, but it's built on a Linux system. I already have a native module which uses "prebuild". To install dependecies I run:

CI=1 npm_config_platform=win32 npm_config_arch=x64 npm_config_target=9.1.1 npm_config_runtime=electron npm ci

This has been working correctly.

Now I need to add another native module: ffi-napi. They use prebuildify according to this pull request. It seems, it doesn't work the same way here.

I get this error message:

[email protected] install /.../myapp/node_modules/ffi-napi
node-gyp-build
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: 404 response downloading https://nodejs.org/dist/v9.1.1/node-v9.1.1-headers.tar.gz

I see two major problems here:

  1. It tries to download headers for NodeJS v9.1.1, but "9.1.1" is the version of Electron. I guess there is no NodeJS 9.1.1 and that's probably the cause for the 404 status code.
  2. Downloading headers means it's trying to build instead of using the prebuild - but I'm not sure about that.

It's interesting that ff-napi also has another native dependencies ref-napi and that it seems there are no problems with that:

[email protected] install /.../myapp/node_modules/ref-napi
node-gyp-build
[email protected] install /.../myapp/node_modules/ffi-napi
gyp WARN install got an error, rolling back install
(see above)

@fishbone1
Copy link
Author

It seems the problem is that

prebuild-install has two arguments: runtime and target

VS

node-gyp-build has one argument target for both values with format [email protected]

So either the first native module installs successfully or the second :-(

@mafintosh
Copy link
Collaborator

I think this is a problem with the FFI module.

I just did some testing myself, on my mac, and when I install ffi-napi it also starts to compile.
It does that because the test to load the prebuild fails.

You can repro this (sometimes) doing this

cd ffi-napi
node -e "require('./prebuilds/darwin-x64/node.napi.uv1.node')"
Assertion failed: (0), function uv_close, file ../deps/uv/src/unix/core.c, line 174.
Abort trap: 6

Might wanna open an issue there about that. My guess is that the dispose logic has some bug potentially, https://github.com/node-ffi-napi/node-ffi-napi/blob/master/src/ffi.cc#L17

@fishbone1
Copy link
Author

Yes I can see that it also starts to compile, even if I remove the first (prebuild) module. A question about that: How is ffi-napi responsible for that? I thought this decision is made by node-gyp-build? I understand your case, because you directly require() it, but in my case I just run npm install and I cannot see a hook or something. (I'm just curious how that works)

But even if it wouldn't compile there is still a compatibility issue between prebuild-install and node-gyp-build as they treat the target parameter differently (see my comment above).

@johnjcool
Copy link

perhaps this could be helpful

package.json:

{
  ...
  "scripts": {
    ...
    "postinstall": "electron-builder install-app-deps && rm -rf ./node_modules/ffi-napi/build",
    ...
  }
  ...
}

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

3 participants