electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
https://www.electron.build
MIT License
13.72k stars 1.74k forks source link

arm64 dmg can be installed on M1 Mac,but run error:no suitable image found. #6630

Open xintengbao opened 2 years ago

xintengbao commented 2 years ago

compile command: package.json "scripts"{ "build-prod": "cross-env ENV=prod node scripts/build.js && electron-builder", ………… } “mac”: { …… "target": { "target": "dmg", "arch": ["x64","arm64"] }

Both build x64 and arm64 at the same time, skip signature, x64 dmg on Intel chip and M1 chip run OK. arm64 dmg can be installed on M1 Mac successfully,but an error occurred while running. build universal version also run error on M1 Mac.

Uncaught Exception: Error: dlopen(/var/folders/db/zy8jss1s0zn_3cnj1spg0y400000gn/T/.com.huawei.linknow.s6t6Y1, 1): no suitable image found. Did find: /var/folders/db/zy8jss1s0zn_3cnj1spg0y400000gn/T/.com.huawei.linknow.s6t6Y1: mach-o, but wrong architecture /var/folders/db/zy8jss1s0zn_3cnj1spg0y400000gn/T/.com.huawei.linknow.s6t6Y1: stat() failed with errno=17 at process.func [as dlopen] (electron/js2c/asar_bundle.js:5:1846) at Object.Module._extensions..node (internal/modules/cjs/loader.js:1138:18) at Object.func [as .node] (electron/js2c/asar_bundle.js:5:2073) at Module.load (internal/modules/cjs/loader.js:935:32) at Module._load (internal/modules/cjs/loader.js:776:14) at Function.f._load (electron/js2c/asar_bundle.js:5:12684) at Module.require (internal/modules/cjs/loader.js:959:19) at require (internal/modules/cjs/helpers.js:88:18) at bindings (/Users/linknowtest/Desktop/test/build/mac-arm64/Link Now.app/Contents/Resources/app.asar/node_modules/bindings/bindings.js:112:48) [at Object. (/Users/linknowtest/Desktop/test/build/mac-arm64/Link Now.app/Contents/Resources/app.asar/node_modules/@cloudplatform/grs-mac/src/addonlib/](mailto:at%20Object.%3Canonymous%3E%20(/Users/linknowtest/Desktop/test/build/mac-arm64/Link%20Now.app/Contents/Resources/app.asar/node_modules/@cloudplatform/grs-mac/src/addonlib/)

indutny-signal commented 2 years ago

I believe M1 laptops require the app to be signed in order to run it. Give a try to: xattr -rc /Applications/YourAppNameHere.app before running the app.

famingyuan commented 2 years ago

build one arch at once . It works for me .

mmaietta commented 2 years ago

I have a hunch as to why you would get wrong arch. Might be a bug in an upstream dependency.

Can you try using electron-rebuild and use these settings in your electron-builder config with beforeBuild hook?

  // force arch build if using electron-rebuild
  beforeBuild: async (context) => {
    const { appDir, electronVersion, arch } = context
    await electronRebuild.rebuild({ buildPath: appDir, electronVersion, arch })
    return false
  },
  nodeGypRebuild: false,
  buildDependenciesFromSource: false,
ganeshrvel commented 2 years ago

Was facing a similar issue https://github.com/electron-userland/electron-builder/issues/6675

npmRebuild solved my issue

  "build": { 
   "npmRebuild": false,
}
stale[bot] commented 2 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.