WiseLibs / better-sqlite3

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

Error while rebuilding for arm #1140

Closed VitorAndrey closed 4 months ago

VitorAndrey commented 5 months ago

Hello! Thnx for your time in advance. I am trying to use better-sqlite3 in my electron aplication wich is supposed to run in raspberry pi 3 so arch amrv7l. I tested in windows at first and it worked perfectly, got this error while rebuilding for this new platform.

me@raspberrypi:~/leitor-de-preco-ts $ LIZ_COMPAT=1
me@raspberrypi:~/leitor-de-preco-ts $ npm i

> leitor-de-preco@1.0.0 postinstall
> electron-builder install-app-deps

  • electron-builder  version=24.9.1
  • loaded configuration  file=/home/me/leitor-de-preco-ts/electron-builder.yml
  • rebuilding native dependencies  dependencies=better-sqlite3@9.4.0 platform=linux arch=armv7l
  • install prebuilt binary  name=better-sqlite3 version=9.4.0 platform=linux arch=armv7l napi=
  • build native dependency from sources  name=better-sqlite3
                                          version=9.4.0
                                          platform=linux
                                          arch=armv7l
                                          napi=
                                          reason=prebuild-install failed with error (run with env DEBUG=electron-builder to get more information)
                                          error=prebuild-install info begin Prebuild-install version 7.1.1
    prebuild-install warn install prebuilt binaries enforced with --force!
    prebuild-install warn install prebuilt binaries may be out of date!
    prebuild-install info looking for local prebuild @ prebuilds/better-sqlite3-v9.4.0-electron-v119-linux-armv7l.tar.gz
    prebuild-install info looking for cached prebuild @ /home/me/.npm/_prebuilds/3289b1-better-sqlite3-v9.4.0-electron-v119-linux-armv7l.tar.gz
    prebuild-install http request GET https://github.com/WiseLibs/better-sqlite3/releases/download/v9.4.0/better-sqlite3-v9.4.0-electron-v119-linux-armv7l.tar.gz
    prebuild-install http 404 https://github.com/WiseLibs/better-sqlite3/releases/download/v9.4.0/better-sqlite3-v9.4.0-electron-v119-linux-armv7l.tar.gz
    prebuild-install warn install No prebuilt binaries found (target=28.2.2 runtime=electron arch=armv7l libc= platform=linux

What I already tried: setting the LIZ_COMPAT=1 env variable as I found in old issues.

Prinzhorn commented 5 months ago

This is not an error but a warning that no prebuild was found. You should still be able to compile locally.

@m4heshd any idea why there is no linux arm prebuild for v119? Looking at the assets https://github.com/WiseLibs/better-sqlite3/releases/tag/v9.4.0 I'm confused why for some versions they are missing? E.g. v115 and v120 have linux arm builds, but not v119

VitorAndrey commented 5 months ago

@Prinzhorn Thanks for helping! I'm sorry if this is trivial, but I've never done it before. I just need to download the corresponding package version for my architecture at https://github.com/WiseLibs/better-sqlite3/releases/tag/v9.4.0? After that, how do I compile locally?

Prinzhorn commented 5 months ago

@VitorAndrey this all happens automatically when prebuild fails, but you've seem to have that disabled

warn install prebuilt binaries enforced with --force

m4heshd commented 5 months ago

@m4heshd any idea why there is no Linux arm prebuild for v119?

Module version 119 is reserved by Electron (v28 to be specific). Unfortunately, we're not building for Electron on arm at the moment.

Now that arm is sort of becoming major on desktop, practically we should build for Electron on arm but the current method we're using to build for arm is notoriously slow. Qemu has a reputation for being just that. BS3's build workflow would take days to finish if we were to do that.

I recently added a feature to BS3 for building arm64 binaries natively on mac. As I mentioned in the PR note, there IS a possibility of building Linux arm builds on that very same runner. But still, I'm not exactly sure how armv7 builds would behave in that environment. Technically, should build fine with similar performance as arm64 builds. Can't be sure till we try though.

UPDATE: Unfortunately, this won't be a possibility in the near future since M1 lacks support for nested virtualization. Just learned this, not a mac user myself. So it's a no-go for Qemu and any sort of emulation on this runner.

VitorAndrey commented 4 months ago

@Prinzhorn, @m4heshd, thank you so much for your time and assistance. It turns out that using Electron Rebuild worked. I ran electron-rebuild -f -w better-sqlite3, and it generated all the necessary components to make the library work in the Raspberry Pi 3 environment.