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.56k stars 1.73k forks source link

macOS Intel installs ARM on auto-update #6694

Closed lostdesign closed 2 years ago

lostdesign commented 2 years ago

This issue was reported before, saying that 4.3.7 would have resolved the issue made me upgrade to 4.6.5 for electron-updater. I tried building locally and updating it which initially worked but testing it from an official release broke the app yet again.

What else could I try to fix this issue? The repo is https://github.com/lostdesign/linked The error occurs in tag 1.4.9, 1.4.10 and 1.4.11 - removed m1 in tag 1.4.12 and everything works as expected again obvs.

        mac: {
          hardenedRuntime: true,
          entitlements: './build/entitlements.mac.inherit.plist',
          // Disabled m1 due to it messing with the auto updating
          //target: {
          //  target: 'default',
          //  arch: ['arm64', 'x64']
          //}
        },

Thanks in advance!

mmaietta commented 2 years ago

Just curious, why not use arch: 'universal' for a single build?

lostdesign commented 2 years ago

Just curious, why not use arch: 'universal' for a single build?

What does that do @mmaietta ? I explicitly listed both as I came across that in other repos and thought you do need to handle them differently.

edit: Just checked https://github.com/electron/universal and guess I won't use universal since that would make the app 400mb big 👀

mmaietta commented 2 years ago

What do these return on your mac that is incorrectly installing an ARM update?

sysctl sysctl.proc_translated 
uname -a

Alternatively, can you add more logging for the auto updater? https://www.electron.build/auto-update#debugging

lostdesign commented 2 years ago
➜  code sysctl sysctl.proc_translated
sysctl: unknown oid 'sysctl.proc_translated'
Darwin lostdesign-mbp.local 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:54 PST 2021; root:xnu-8019.61.5~1/RELEASE_X86_64 x86_64

And yes, I will add more logging to the autoupdater to check locally. Should have done that in the first place..

vitalyso commented 2 years ago

We have a similar issue, the only difference it updates the ARM version to Intel. We have a different order in the arch though (['x64', 'arm64']), so my hypothesis is it takes the first URL in the latest-mac.yml and downloads it.

currentoor commented 2 years ago

We have a similar issue, the only difference it updates the ARM version to Intel. We have a different order in the arch though (['x64', 'arm64']), so my hypothesis is it takes the first URL in the latest-mac.yml and downloads it.

I have the same issue too. My latest-mac.yml looks like this

version: 5.0.6
files:
  - url: mutesync-5.0.6-mac.zip
    sha512: nHsY/tA0KMRNJNCweNFAF2/4BDp/IN5rBb01LaQihq4Kyr6EnjBjouMIKNnIiQJ9ENTNJj8m1MkCoZ1Y0oG+Lg==
    size: 91497931
  - url: mutesync-5.0.6.dmg
    sha512: 4TW/O1W3b3V8bIhlzXLDVhhVBlq4XBmtXUPyS/I3dcqgZ28rrDR35x3s8rhq73N0FNg6OEadYD/oGIBEJpCYLg==
    size: 94820970
  - url: mutesync-5.0.6.dmg
    sha512: 4TW/O1W3b3V8bIhlzXLDVhhVBlq4XBmtXUPyS/I3dcqgZ28rrDR35x3s8rhq73N0FNg6OEadYD/oGIBEJpCYLg==
    size: 94820970
  - url: mutesync-5.0.6.dmg
    sha512: 4TW/O1W3b3V8bIhlzXLDVhhVBlq4XBmtXUPyS/I3dcqgZ28rrDR35x3s8rhq73N0FNg6OEadYD/oGIBEJpCYLg==
    size: 94820970
path: mutesync-5.0.6-mac.zip
sha512: nHsY/tA0KMRNJNCweNFAF2/4BDp/IN5rBb01LaQihq4Kyr6EnjBjouMIKNnIiQJ9ENTNJj8m1MkCoZ1Y0oG+Lg==
releaseDate: '2022-02-23T17:51:37.930Z'

In package.json I have

      "target": [
        {
          "target": "default"
        }
      ]

To publish I use

yarn electron-builder build -m -p always --arm64
yarn electron-builder build -m -p always --x64

But I did notice the arm64 build is uploaded correctly. I can't use a universal build because my app has a lot of native code that needs to be built individually for each architecture.

mmaietta commented 2 years ago

I can't use a universal build because my app has a lot of native code that needs to be built individually for each architecture.

Universal is able to stitch together native code into a "fat" dylib, so after you built individually for each architecture, @electron/universal package is supposed to handle the combination.

currentoor commented 2 years ago

I can't use a universal build because my app has a lot of native code that needs to be built individually for each architecture.

Universal is able to stitch together native code into a "fat" dylib, so after you built individually for each architecture, @electron/universal package is supposed to handle the combination.

Oh cool, but it would still result in a huge file that will annoy my users.

Do you have any idea where this bug (upgrade to the wrong architecture) might be? Maybe I can try fixing it, I tried updating to the latest version.

vitalyso commented 2 years ago

@currentoor it was resolved for us by upgrading to the latest version of electron-builder, probably will help you as well

lostdesign commented 2 years ago

@currentoor it was resolved for us by upgrading to the latest version of electron-builder, probably will help you as well

Can you share your build config?

currentoor commented 2 years ago

@currentoor it was resolved for us by upgrading to the latest version of electron-builder, probably will help you as well

Can you share your build config?

@sivkoff @mmaietta upgrading to the latest version fixed the issue for me too, thanks!

@lostdesign this is what the mac portion of our build config looks like

    "mac": {
      "category": "public.app-category.productivity",
      "entitlements": "build/entitlements.mac.plist",
      "entitlementsInherit": "build/entitlements.mac.plist",
      "extendInfo": {
        "LSUIElement": 1
      },
      "gatekeeperAssess": false,
      "hardenedRuntime": true,
      "target": [
        {
          "target": "default",
          "arch": [
            "arm64",
            "x64"
          ]
        }
      ]
    },
    "dmg": {
      "sign": false,
      "window": {
        "width": 540,
        "height": 380
      },
      "contents": [
        {
          "x": 120,
          "y": 224
        },
        {
          "x": 415,
          "y": 220,
          "type": "link",
          "path": "/Applications"
        }
      ]
    },

And we deploy via

yarn electron-builder build -m -p always
vitalyso commented 2 years ago

@lostdesign it's very similar to @currentoor's config:

"mac": {
  "category": "public.app-category.productivity",
  "target": [
    {
      "target": "zip",
      "arch": [
        "x64",
        "arm64"
      ]
    }
  ],
  "icon": "resources/icons/png/icon.png",
  "hardenedRuntime": true,
  "gatekeeperAssess": false,
  "entitlements": "resources/entitlements.mac.plist",
  "entitlementsInherit": "resources/entitlements.mac.plist"
}
moloch-- commented 2 years ago

Is there just a way to specify the yml filename used by the updater?

mmaietta commented 2 years ago

@moloch-- no sorry, it is not possible to manually provide an updater config. Happy to review a PR if you'd like to contribute to that functionality!

Closing this issue since multiple people are reporting it fixed in the latest version