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

Cannot pack macOS universal app in v25.0.0: the same architectures can't be in the same fat output file #8347

Closed
gzdunek opened this issue Jul 17, 2024 · 6 comments · Fixed by #8352 or #8343

Comments

@gzdunek
Copy link

gzdunek commented Jul 17, 2024

  • Electron-Builder Version: 25.0.0
  • Node Version: 20.15.1
  • Electron Version: 31.2.1
  • Electron Type (current, beta, nightly):
  • Target: universal

After updating electron-builder to 25.0.0 packaging an universal app that has a native dependency fails with an error:


> electron-quick-start@1.0.0 build
> electron-builder build --universal

  • electron-builder  version=25.0.0 os=23.5.0
  • writing effective config  file=dist/builder-effective-config.yaml
  • executing @electron/rebuild  electronVersion=31.2.1 arch=x64 buildFromSource=false appDir=./
  • installing native dependencies  arch=x64
  • preparing       moduleName=node-pty arch=x64
  • finished        moduleName=node-pty arch=x64
  • completed installing native dependencies
  • packaging       platform=darwin arch=x64 electron=31.2.1 appOutDir=dist/mac-universal-x64-temp
  • default Electron icon is used  reason=application icon is not set
  • executing @electron/rebuild  electronVersion=31.2.1 arch=arm64 buildFromSource=false appDir=./
  • installing native dependencies  arch=arm64
  • preparing       moduleName=node-pty arch=arm64
  • finished        moduleName=node-pty arch=arm64
  • completed installing native dependencies
  • packaging       platform=darwin arch=arm64 electron=31.2.1 appOutDir=dist/mac-universal-arm64-temp
  • packaging       platform=darwin arch=universal electron=31.2.1 appOutDir=dist/mac-universal
fatal error: /Library/Developer/CommandLineTools/usr/bin/lipo: /private/var/folders/y5/yqg8xz555_v7xfsr0wn6b4q80000gn/T/arm64-D1MK41/node_modules/node-pty/bin/darwin-arm64-125/node-pty.node and /private/var/folders/y5/yqg8xz555_v7xfsr0wn6b4q80000gn/T/x64-tztgm9/node_modules/node-pty/bin/darwin-arm64-125/node-pty.node have the same architectures (arm64) and can't be in the same fat output file
  ⨯ Command failed: lipo /private/var/folders/y5/yqg8xz555_v7xfsr0wn6b4q80000gn/T/arm64-D1MK41/node_modules/node-pty/bin/darwin-arm64-125/node-pty.node /private/var/folders/y5/yqg8xz555_v7xfsr0wn6b4q80000gn/T/x64-tztgm9/node_modules/node-pty/bin/darwin-arm64-125/node-pty.node -create -output /private/var/folders/y5/yqg8xz555_v7xfsr0wn6b4q80000gn/T/x64-tztgm9/node_modules/node-pty/bin/darwin-arm64-125/node-pty.node
fatal error: /Library/Developer/CommandLineTools/usr/bin/lipo: /private/var/folders/y5/yqg8xz555_v7xfsr0wn6b4q80000gn/T/arm64-D1MK41/node_modules/node-pty/bin/darwin-arm64-125/node-pty.node and /private/var/folders/y5/yqg8xz555_v7xfsr0wn6b4q80000gn/T/x64-tztgm9/node_modules/node-pty/bin/darwin-arm64-125/node-pty.node have the same architectures (arm64) and can't be in the same fat output file
  failedTask=build stackTrace=Error: Command failed: lipo /private/var/folders/y5/yqg8xz555_v7xfsr0wn6b4q80000gn/T/arm64-D1MK41/node_modules/node-pty/bin/darwin-arm64-125/node-pty.node /private/var/folders/y5/yqg8xz555_v7xfsr0wn6b4q80000gn/T/x64-tztgm9/node_modules/node-pty/bin/darwin-arm64-125/node-pty.node -create -output /private/var/folders/y5/yqg8xz555_v7xfsr0wn6b4q80000gn/T/x64-tztgm9/node_modules/node-pty/bin/darwin-arm64-125/node-pty.node
fatal error: /Library/Developer/CommandLineTools/usr/bin/lipo: /private/var/folders/y5/yqg8xz555_v7xfsr0wn6b4q80000gn/T/arm64-D1MK41/node_modules/node-pty/bin/darwin-arm64-125/node-pty.node and /private/var/folders/y5/yqg8xz555_v7xfsr0wn6b4q80000gn/T/x64-tztgm9/node_modules/node-pty/bin/darwin-arm64-125/node-pty.node have the same architectures (arm64) and can't be in the same fat output file
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      at genericNodeError (node:internal/errors:984:15)

I believe this is the result of missing disablePreGypCopy: true flag in @electron/rebuild options, which was added in #7519 but later removed.
After I patched node_modules/app-builder-lib/out/util/yarn.js the build passes.

Repro: https://github.com/gzdunek/electron-builder-universal - run npm run build
(when running for the first time the actual error is different, re-running it returns an error as above).

@gzdunek gzdunek changed the title Cannot pack universal app in v25.0.0: the same architectures can't be in the same fat output file Cannot pack macOS universal app in v25.0.0: the same architectures can't be in the same fat output file Jul 17, 2024
@mmaietta
Copy link
Collaborator

@gzdunek can you share the patch you are using?

Also, (hopefully) to temporarily unblock you, you may be able to use electron-builder config option nativeRebuilder: legacy to leverage the previous app-builder-bin go binary for rebuilding native dependencies.

@gzdunek
Copy link
Author

gzdunek commented Jul 18, 2024

Here is the patch:

diff --git a/node_modules/app-builder-lib/out/util/yarn.js b/node_modules/app-builder-lib/out/util/yarn.js
index d4a95ba..a2ab75b 100644
--- a/node_modules/app-builder-lib/out/util/yarn.js
+++ b/node_modules/app-builder-lib/out/util/yarn.js
@@ -169,6 +169,7 @@ async function rebuild(config, appDir, options) {
         debug: builder_util_1.log.isDebugEnabled,
         projectRootPath: await (0, search_module_1.getProjectRootPath)(appDir),
         mode: config.nativeRebuilder || "sequential",
+        disablePreGypCopy: true
     };
     if (buildFromSource) {
         rebuildOptions.prebuildTagPrefix = "totally-not-a-real-prefix-to-force-rebuild";

Also, (hopefully) to temporarily unblock you, you may be able to use electron-builder config option nativeRebuilder: legacy to leverage the previous app-builder-bin go binary for rebuilding native dependencies.

Well, we had troubles with that too :)
In our monorepo setup (yarn 1.x) the legacy builder didn't find the native dependency at all (in the debug mode it logs no native dependencies). Because of that, in the universal package, the dependency wasn't rebuilt for x86 arch and the app crashed in the runtime.
This seems to be a regression too, it worked fine in electron-builder@24.13.3.

@mmaietta
Copy link
Collaborator

Thanks for the patch info!

I'm wondering if we should always disablePreGypCopy: true for the electron/rebuild integration. I haven't seen other reports yet for this issue, but current adoption of 25.0.0 is fairly low atm (only 624 downloads as of this moment)

@mmaietta
Copy link
Collaborator

Thank you for the test repo. I've opened a PR to resolve this issue since I was also able to reproduce and updated a unit test to cover the universal mac packaging with node-pty. Just updating test snapshots now

@mmaietta
Copy link
Collaborator

Please give 25.0.1 a shot and lemme know how it goes! Was no longer able to reproduce with the applied changes

@gzdunek
Copy link
Author

gzdunek commented Jul 19, 2024

25.0.1 solved the issue, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants