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

support native modules in new electron version v15 #6352

Closed
kevinwang930 opened this issue Oct 17, 2021 · 11 comments
Closed

support native modules in new electron version v15 #6352

kevinwang930 opened this issue Oct 17, 2021 · 11 comments

Comments

@kevinwang930
Copy link

kevinwang930 commented Oct 17, 2021

  • Electron-Builder Version: 22.14.5
  • Node Version: v16.11
  • Electron Version: v15.2.0
  • Electron Type (current, beta, nightly): current
  • Target: nsis

electron-builder command install-app-deps only works with electron version ^13 when building native modules, can anyone kindly explain what is the situation now ?

@github-actions github-actions bot added the nsis label Oct 17, 2021
@mmaietta
Copy link
Collaborator

only works with electron version ^13

That's bizarre, it's worked historically for many different versions of electron for me.
Are you saying that it no longer works specifically for electron 15?

@kevinwang930
Copy link
Author

kevinwang930 commented Oct 17, 2021

@mmaietta It's the node abi version problem I think , below is the error info, I tried manually install the node-abi, problem persists

> electron-builder install-app-deps

  • electron-builder  version=22.14.5
  • loaded configuration  file=E:\code\myApp\electron-builder.yml
  • rebuilding native dependencies  dependencies=better-sqlite3@7.4.3 platform=win32 arch=x64
  • install prebuilt binary  name=better-sqlite3 version=7.4.3 platform=win32 arch=x64 napi=
  • build native dependency from sources  name=better-sqlite3
                                          version=7.4.3
                                          platform=win32
                                          arch=x64
                                          napi=
                                          reason=prebuild-install failed with error (run with env DEBUG=electron-builder to 
get more information)
                                          error=E:\code\myApp\node_modules\node-abi\index.js:36
      throw new Error('Could not detect abi for version ' + target + ' and runtime ' + runtime + '.  Updating "node-abi" might help solve this issue if it is a new release of ' + runtime)
      ^

    Error: Could not detect abi for version 15.2.0 and runtime electron.  Updating "node-abi" might help solve this issue if it is a new release of electron
        at getAbi (E:\code\myApp\node_modules\node-abi\index.js:36:9)
        at module.exports (E:\code\myApp\node_modules\prebuild-install\rc.js:52:57)
        at Object.<anonymous> (E:\code\myApp\node_modules\prebuild-install\bin.js:8:25)
        at Module._compile (node:internal/modules/cjs/loader:1101:14)
        at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
        at Module.load (node:internal/modules/cjs/loader:981:32)
        at Function.Module._load (node:internal/modules/cjs/loader:822:12)
        at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
        at node:internal/main/run_main_module:17:47


up to date, audited 1745 packages in 23s

@vladimiry
Copy link
Contributor

vladimiry commented Oct 25, 2021

Works for me with @electron v15 for 5 native modules. So it's apparently the issue of the better-sqlite3 itself.

@kevinwang930
Copy link
Author

kevinwang930 commented Oct 25, 2021

@vladimiry yeah, better-sqlite3 needs update, but this raise another question, can we jump the native module check for some modules? actually I can manually rebuild better-sqlite3 with node-gyp or use build-release script in better-sqlite3 package.json.

@Prinzhorn
Copy link

Works for me with @electron v15 for 5 native modules. So it's apparently the issue of the better-sqlite3 itself.

@vladimiry could you share which modules you've tested this with? I'm curious how their prebuild setup and install scripts look compared to better-sqlite3.

@vladimiry
Copy link
Contributor

vladimiry commented Oct 25, 2021

@Prinzhorn
Copy link

don't use prebuilds here but drop them and also drop ./node_modules/prebuild-install and then trigger the rebuild by electron-builder install-app-deps

Gotcha, thanks! The problem with better-sqlite3 is precisely that wrong prebuilds are generated, probably because prebuild depends on outdated node-abi (or node-abi in general is not up to date).

@m4heshd
Copy link

m4heshd commented Nov 14, 2021

@vladimiry There's no issue with the prebuilds. prebuild uses an up-to-date version of node-abi which does the job fine. I've carefully tracked the issue down to app-builder-bin which seem to be using an old version of prebuild-install (not sure, probably). It simply fetches the incorrect prebuild asset. prebuild-install just updated node-abi only two days ago.

Deps used in my test case:

  • Electron - 15.3.1 (ABI - 98)
  • electron-builder - 22.13.1
  • better-sqlite3-multiple-ciphers - 7.4.4

In my test, app-builder-bin seems to be fetching better-sqlite3-multiple-ciphers-v7.4.4-electron-v89-win32-x64.tar.gz instead of better-sqlite3-multiple-ciphers-v7.4.4-electron-v98-win32-x64.tar.gz. Once I manually download the latter and set it up, everything works as expected. It leads to the conclusion that prebuild did the job correctly.

Possible cause:

If you look at electron-releases you'll see that Electron used ABI version 89 till the release of v15.0.0-beta.7.

image

I'm baffled by why that is because I usually see @codebytere snatching these ABI versions up during nightly releases but in the end this seem to have messed up a lot of native dependency related tools.

We just need an update for app-builder-bin. I hope @develar can shed some light on this.

@vladimiry
Copy link
Contributor

@vladimiry There's no issue with the prebuilds.

I didn't say that there is an issue with prebuilds, it's your words, but that I don't use prebuilds at all. So I'm more interested in the native modules to be compilable at my side than being served with correct prebuilds.

@m4heshd
Copy link

m4heshd commented Nov 14, 2021

Ok scratch my previous rant. I just realized while looking through the source of app-builder, that it uses whatever version of prebuild-install installed in the root project or through a peer. So we just need to update prebuild-install to 7.0.0.

I didn't say that there is an issue with prebuilds, it's your words

What I tried to respond to was you saying it's something wrong with better-sqlite3. Bad wording on my part.

So I'm more interested in the native modules to be compilable at my side than being served with correct prebuilds.

Prebuilt assets makes large workflows run faster and makes the process of trying it out much easier for fairly new users. Otherwise the issue tracker gets polluted by users asking "How to compile?". Just my opinion.

For the moment, even installing the latest version of prebuild-install on the root project would do the trick.

@stale
Copy link

stale bot commented Apr 16, 2022

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the backlog label Apr 16, 2022
@stale stale bot closed this as completed Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants