WiseLibs / better-sqlite3

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

Issue Encountered During Electron Packaging with Apple Silicon Architecture #1089

Closed vluma closed 9 months ago

vluma commented 9 months ago

I'm facing an issue while packaging an Electron app using version 26.2.4 and better-sqlite3 8.7.0. The packaging process involves using the "inter" processor with targets for both x64 architecture on a 2020 MacBook and arm64 architecture.

截屏2023-10-17 18 54 34

During the packaging process, better-sqlite3 is recompiled, and everything works as expected on the x64 architecture. However, on the arm64 architecture, I encounter the following error:

截屏2023-10-17 18 52 46
Prinzhorn commented 9 months ago

The packaging process involves using the "inter" processor with targets for both x64 architecture on a 2020 MacBook and arm64 architecture.

I have no idea what this means, search engines will even correct "+inter processor" to "Intel". Are you saying MacBooks support two separate architectures at once?

During the packaging process, better-sqlite3 is recompiled, and everything works as expected on the x64 architecture. However, on the arm64 architecture, I encounter the following error:

You can't run a x64 on arm64, you need to provide two versions of your Electron app.

vluma commented 9 months ago

During the packaging process on my x64 computer (see Image 1), there is a noticeable step indicating the re-download of better-sqlite3 for different architectures.

After completing the packaging, the x64 build runs smoothly on my computer. However, when I share the arm build with a friend, they encounter an error on their computer.

"target": [ { "target": "dmg", "arch": [ "x64", "arm64" ] }, { "target": "zip", "arch": [ "x64", "arm64" ] } ] To address this, I'm considering manually reinstalling dependencies and then packaging separately for each architecture. Is this the recommended approach, and are there specific steps or considerations I should be aware of in this process?

Your guidance on resolving this cross-architecture compatibility issue and achieving successful builds for both x64 and arm architectures would be greatly appreciated. Thank you for your assistance!

neoxpert commented 9 months ago

Have you tried using Electron 25? Or the combination of Electron 27 and better-sqlite3 9.0.0? Electron 26 does require a recompile due to fact that it shares its ABI version with Electron 25 rendering the prebuilt binaries incompatible anyways. When using the multi arch target settings, all native binaries should be available as suitable prebuilt ones as otherwise they have to be recompiled using proper toolchains.

I had no problems packaging an App for Electron 27 and better-sqlite3 9.0.0 for x64 and arch64 from a 10.15 (Catalina) environment.

vluma commented 9 months ago

You're welcome! After updating Electron to version 27 and Better SQLite to version 9, the packaging process was successful.