WiseLibs / better-sqlite3

The fastest and simplest library for SQLite3 in Node.js.
MIT License
5.26k stars 391 forks source link

Build fails for electron v26.1 on opening #1060

Closed coltoneshaw closed 10 months ago

coltoneshaw commented 10 months ago

Electron: v26.1.0 Electron-builder: v24.6.4 Better-sqlite3: v8.6.0

When attempting to build via electron-builder I get the below error. If I adjust the node-abi version in the rebuild package from 3.3.0 to 3.47.0 it builds it without the failure but the app crashes on opening. I think it could be related to #1044

Build build failure with OG prebuild deps

This fails to build, but the application opens just fine and nothing seems to be wrong.

  • build native dependency from sources  name=better-sqlite3
                                          version=8.6.0
                                          platform=darwin
                                          arch=x64
                                          napi=
                                          reason=prebuild-install failed with error (run with env DEBUG=electron-builder to get more information)
                                          error=/Users/coltonshaw/Desktop/scripts/pcomvp-desktop/node_modules/prebuild-install/node_modules/node-abi/index.js:39
      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 26.1.0 and runtime electron.  Updating "node-abi" might help solve this issue if it is a new release of electron
        at getAbi (/Users/coltonshaw/Desktop/scripts/pcomvp-desktop/node_modules/prebuild-install/node_modules/node-abi/index.js:39:9)
        at module.exports (/Users/coltonshaw/Desktop/scripts/pcomvp-desktop/node_modules/prebuild-install/rc.js:54:57)
        at Object.<anonymous> (/Users/coltonshaw/Desktop/scripts/pcomvp-desktop/node_modules/prebuild-install/bin.js:8:27)
        at Module._compile (node:internal/modules/cjs/loader:1233:14)
        at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
        at Module.load (node:internal/modules/cjs/loader:1091:32)
        at Module._load (node:internal/modules/cjs/loader:938:12)
        at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
        at node:internal/main/run_main_module:23:47

    Node.js v20.5.1

Build success, failure to open

To ensure your native dependencies are always matched electron version, simply add script `"postinstall": "electron-builder install-app-deps" to your `package.json`
  • writing effective config  file=dist/builder-effective-config.yaml
  • rebuilding native dependencies  dependencies=better-sqlite3@8.6.0 platform=darwin arch=x64
  • install prebuilt binary  name=better-sqlite3 version=8.6.0 platform=darwin arch=x64 napi=
  • packaging       platform=darwin arch=x64 electron=26.2.0 appOutDir=dist/mac
  • downloading     url=https://github.com/electron/electron/releases/download/v26.2.0/electron-v26.2.0-darwin-x64.zip size=94 MB parts=8
  • downloaded      url=https://github.com/electron/electron/releases/download/v26.2.0/electron-v26.2.0-darwin-x64.zip duration=12.383s
  • signing         file=dist/mac/PCO MVP.app identityName=Developer ID Application: Colton Shaw (4UHVHSRL22) identityHash=B22AEB9D9BCF2EAAC4FAD28C290D825A19055CEA provisioningProfile=none
  • building        target=DMG arch=x64 file=dist/pcomvp-desktop-2.1.1-mac-x64.dmg
  • building        target=macOS zip arch=x64 file=dist/pcomvp-desktop-2.1.1-mac-x64.zip
  • Detected arm64 process, HFS+ is unavailable. Creating dmg with APFS - supports Mac OSX 10.12+
  • building block map  blockMapFile=dist/pcomvp-desktop-2.1.1-mac-x64.dmg.blockmap
  • building block map  blockMapFile=dist/pcomvp-desktop-2.1.1-mac-x64.zip.blockmap

Screenshot 2023-09-10 at 10 36 44 AM

Prinzhorn commented 10 months ago

I think it could be related to #1044

It is exactly that. It says " install prebuilt binary name=better-sqlite3 version=8.6.0 platform=darwin arch=x64 napi=" so you've downloaded the broken prebuild. You need to force the package to be compiled for Electron 26 as described in that issue.

coltoneshaw commented 10 months ago

@Prinzhorn - Awesome, thanks. I didn't think that meant it was the same issue since it always downloads a prebuilt binary. So, effectively everyone on electron v26 is most likely broken? I'll close this and test the other fix though, thank you!

Prinzhorn commented 10 months ago

So, effectively everyone on electron v26 is most likely broken?

It looks like it, yes