Skip to content

Native Dependencies missing in electron-builder 24 #7621

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

Closed
MuhKuh7 opened this issue Jun 19, 2023 · 15 comments
Closed

Native Dependencies missing in electron-builder 24 #7621

MuhKuh7 opened this issue Jun 19, 2023 · 15 comments

Comments

@MuhKuh7
Copy link

MuhKuh7 commented Jun 19, 2023

I am building for Windows on a Linux machine. With electron-builder 23 that works fine and I can see that the native dependencies (keytar in my case) are handled.

> electron-builder install-app-deps

  • electron-builder  version=23.6.0
  • loaded configuration  file=package.json ("build" field)
  • loaded parent configuration  preset=react-cra
  • rebuilding native dependencies  [email protected], [email protected] platform=win32 arch=x64
  • install prebuilt binary  name=keytar version=7.9.0 platform=win32 arch=x64 napi=

But when I update to version 24, the application built on Linux does not run on Windows anymore and throws a "not a win32 application" error. When built on Windows it works. From the output I noticed that there is no mention anymore of the native dependencies.

> electron-builder install-app-deps

  • electron-builder  version=24.4.0
  • loaded configuration  file=package.json ("build" field)
  • loaded parent configuration  preset=react-cra
  • executing @electron/rebuild  arch=x64 version=25.1.1 appDir=/opt/work/93594e21797f15d9/app
@mmaietta
Copy link
Collaborator

We had to transition to the official electron/rebuild package due to newer Electron versions requiring additional compiler flags.
I'm wondering if you're running into this issue #7465

Can you create a sample repo to reproduce this? I can investigate on it locally.

@mmaietta
Copy link
Collaborator

Can you please try release 24.5.1 and report back if that resolves your issue?

@MuhKuh7
Copy link
Author

MuhKuh7 commented Jun 25, 2023

Can you please try release 24.5.1 and report back if that resolves your issue?

Unfortunately still the same with version 24.5.1

@s00d
Copy link
Contributor

s00d commented Jun 27, 2023

Can you please try release 24.5.1 and report back if that resolves your issue?

Unfortunately still the same with version 24.5.1

try 24.5.1 and npmRebuild: true, it's help me

@MuhKuh7
Copy link
Author

MuhKuh7 commented Jul 12, 2023

try 24.5.1 and npmRebuild: true, it's help me

doesn't do anything for me

@mmaietta
Copy link
Collaborator

Can you please try 24.6.1? 🤞

@MuhKuh7
Copy link
Author

MuhKuh7 commented Jul 20, 2023

Now the build fails ;)

> electron-builder install-app-deps

  • electron-builder  version=24.6.1
  • loaded configuration  file=package.json ("build" field)
  • loaded parent configuration  preset=react-cra
  ⨯ Cannot read properties of undefined (reading 'value')  failedTask=installAppDeps stackTrace=TypeError: Cannot read properties of undefined (reading 'value')
    at rebuild (/app/node_modules/app-builder-lib/src/util/yarn.ts:169:49)
    at installOrRebuild (/app/node_modules/app-builder-lib/src/util/yarn.ts:29:11)
    at installAppDeps (/app/node_modules/electron-builder/src/cli/install-app-deps.ts:58:3)

@mmaietta
Copy link
Collaborator

On it! Will attempt to take a look tonight

@mmaietta
Copy link
Collaborator

Try 24.6.2 🙂

@MuhKuh7
Copy link
Author

MuhKuh7 commented Jul 23, 2023

Try 24.6.2 🙂

Seems to work now. Only strange thing is that it reports the platform used as "linux" which is the system it is built on instead of "win32" which it is built for. Since the built application runs under Windows I assume it actually used the correct binaries though.

> electron-builder install-app-deps

  • electron-builder  version=24.6.2
  • loaded configuration  file=package.json ("build" field)
  • loaded parent configuration  preset=react-cra
  • rebuilding native dependencies  [email protected] platform=linux arch=x64
  • install prebuilt binary  name=keytar version=7.9.0 platform=linux arch=x64 napi=

@mmaietta
Copy link
Collaborator

I think prebuild installs all OS version? Not sure.

Can this issue be closed?

@universal
Copy link

universal commented Aug 3, 2023

I am running into a similar issue trying to cross-build from linux to windows. I have tried finding the problem on and off for quite a while now, but can't figure it out. The problem might very well be the package with a native dependency I use (https://www.npmjs.com/package/@tauubyebye/win-audio).

I just created a very minimal electron app that exhibits the problem: https://github.com/universal/electron-native-dependencies-cross-build

I am still getting familiar with the whole electron/js-ecosystem and have so far no real clue about how native dependencies work. If the problem is in the used package, a pointer to how to fix it there would be very much appreciated.

I also tried building the app through the docker images and based the command in build.sh off of your example for travis.

If i can help in any way in debugging this I am happy to do/provide whatever you need :-) Your help is very much appreciated.

A little bit further reading indicates that cross-compiling of native dependencies in a package does not really work (as far as i understood it). What should work if precompiled binaries are uploaded to github. The package I use does not have those. I am now trying to figure out how and where to put those.

@mmaietta
Copy link
Collaborator

mmaietta commented Aug 3, 2023

What should work if precompiled binaries are uploaded to github. The package I use does not have those.

If the package does not have those, then you need to compile the dependencies from the source code, meaning you need a Mac and a Windows build node at minimum. (Mac build node can compile Linux .node modules)
Cross-compiling native dependencies is not possible.

@universal
Copy link

thanks for your reply :-) that is what i figured as well. figuring out prebuild/prebuildify now... :-)

@universal
Copy link

finally found something that works. could not get prebuildify to work, but something based on prebuild / prebuild-install appears to be working now :-) hopefully i can now ditch the vms with windows. The forked library is at https://github.com/universal/win-audio if you are looking for some inspiration... haven't added any ci-pipelines here.

so this works for me with 24.6.3 :-)

@mmaietta mmaietta closed this as completed Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants