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

Prebuilt binaries aren't fetched when packaging an Electron app #3828

Closed
kraenhansen opened this issue Jul 6, 2021 · 5 comments · Fixed by #6309
Closed

Prebuilt binaries aren't fetched when packaging an Electron app #3828

kraenhansen opened this issue Jul 6, 2021 · 5 comments · Fixed by #6309
Assignees
Labels

Comments

@kraenhansen
Copy link
Member

kraenhansen commented Jul 6, 2021

Goals

Using electron-builder to install native dependencies for an Electron app using Realm JS for Windows or Linux on a macOS machine.

Expected Results

I expect Electron Builder to recognise Realm JS as having a native module which needs to be installed using prebuild-install.

Actual Results

When building for Windows on a macOS machine, end users of the electron app experience the following error:

Uncaught Error: \\?\C:\Users\bimusiek\AppData\Local\Temp\3da4c319-5a47-4f25-9b04-8a36075b8f09.tmp.node is not a valid Win32 application.

This is because the realm.node binary shipped with the Windows build is actually the binary for macOS which never got replaced when the app was being packaged.

A temporary fix we needed in Realm Studio was this line:

touch node_modules/realm/binding.gyp

My investigations this far concludes: Electron Builder (the electron-builder package on NPM) looks for (at least) the binding.gyp file when determining if a dependency of an electron app has a native module or not. As a consequence Electron builder won't fetch the correct prebuilds when building the app for Windows nor Linux on a macOS machine. The binding.gyp file was removed as we migrated Realm JS to cmake-js.

We could add the empty file to our package, but since that feels a bit like a workaround, I would love to learn of alternative ways to tell electron-builder to consider Realm JS as having native modules which needs to be fetched when packaging up the app.

This could be related to electron/rebuild#268.

Steps to Reproduce

  • Initialize an NPM package with [email protected], [email protected] and [email protected].
  • Try adding native dependencies (npx electron-builder install-app-deps)
  • Notice that realm is not included.
  • Add the binding.gyp file to Realm JS (touch node_modules/realm/binding.gyp)
  • Try adding native dependencies again and notice that realm appears.

Version of Realm and Tooling

  • Realm JS SDK Version: 10.5.0
  • Node or React Native: Electron
  • Client OS & Version: Tested on MacOS
  • Which debugger for React Native: N/A
@bimusiek
Copy link
Contributor

bimusiek commented Jul 6, 2021

@kraenhansen Unfortunately after going through our whole build process, we are not able to compile the Realm for Linux on our OSX machine.

The fix for that is using

    "npmRebuild": false

but then the electron-builder fetches pre-built package from https://static.realm.io and binding.gyp is missing and the same error happens.

Below is the log from our Linux build

  • building        target=AppImage arch=x64 file=dist/__PRODUCT_NAME__-6.0.14.AppImage
  • rebuilding native dependencies  [email protected] platform=linux arch=ia32
  • install prebuilt binary  name=realm version=10.5.0 platform=linux arch=ia32 napi=
  ⨯ cannot build native dependency  reason=prebuild-install failed with error and build from sources not possible because platform or arch not compatible
                                    cause=exit status 1
                                    errorOut=prebuild-install info begin Prebuild-install version 6.1.3
    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/realm-v10.5.0-napi-v4-linux-ia32.tar.gz
    prebuild-install info looking for cached prebuild @ /Users/bimusiek/.npm/_prebuilds/14d29f-realm-v10.5.0-napi-v4-linux-ia32.tar.gz
    prebuild-install http request GET https://static.realm.io/realm-js-prebuilds/10.5.0/realm-v10.5.0-napi-v4-linux-ia32.tar.gz
    prebuild-install http 404 https://static.realm.io/realm-js-prebuilds/10.5.0/realm-v10.5.0-napi-v4-linux-ia32.tar.gz
    prebuild-install WARN install No prebuilt binaries found (target=4 runtime=napi arch=ia32 libc= platform=linux)

                                    command=/Users/bimusiek/Developer/node/out/Release/node /Users/bimusiek/Developer/FreeYourMusic/app/renderer/node_modules/prebuild-install/bin.js --platform=linux --arch=ia32 --target=4 --runtime=napi --verbose --force
                                    workingDir=/Users/bimusiek/Developer/FreeYourMusic/app/renderer/node_modules/realm

@kraenhansen
Copy link
Member Author

@bimusiek it looks like we're currently not publishing prebuilds for 32bit Linux. I've asked my team to confirm weather or not we're considering this combination supported or if 32bit Linux is too much history for us to consider.

Would it be possible for you to build for 64bit Linux instead?

@bimusiek
Copy link
Contributor

bimusiek commented Jul 6, 2021

@kraenhansen I just validated that only 1.3% of our users download Linux app so we are fine with building only for x64 as I guess most of those 1.3% are on x64 already.

We are getting rid of 32bit Linux build then :)

@kraenhansen
Copy link
Member Author

@bimusiek I'm happy to hear you're considering that a viable option. I'll make sure to keep this updated as we find a more permanent solution to the original issue.

@bimusiek
Copy link
Contributor

bimusiek commented Jul 6, 2021

Thank you. I can confirm that the workaround works perfectly 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants