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.67k stars 1.74k forks source link

macOS auto-update always searches for not existing app-update.yml #6811

Open tpetry opened 2 years ago

tpetry commented 2 years ago

When creating an auto-updateable macOS application with the generic provider the electron-updater process always searches for a not-existing app-update.yml and is therefore crashing.

.electron-builder.config.js:

const config = {
  appId: "app.stackbricks.app",
  productName: "StackBricks",
  directories: {
    output: 'dist',
    buildResources: 'buildResources',
  },
  publish: {
    provider: "generic",
    url: "https://stackbricks.app"
  },
  files: [
    'packages/**/dist/**',
  ],
  mac: {
    category: 'public.app-category.developer-tools',
    darkModeSupport: false,
  },
};

module.exports = config;

Electron-Code:

const autoUpdater = new MacUpdater({
    provider: 'generic',
    url: 'http://localhost:8086',
    requestHeaders: {
        'X-OS-ARCH': arch(),
        'X-OS-PLATFORM': platform(),
        'X-OS-RELEASE': release(),
        'X-VERSION': app.getVersion(),
    }
});
autoUpdater.checkForUpdates()

Generated File-Listing:

-rw-r--r--  1 tpetry  staff  96336322 23 Apr 14:36 StackBricks-0.3.0-arm64-mac.zip
-rw-r--r--  1 tpetry  staff    101769 23 Apr 14:36 StackBricks-0.3.0-arm64-mac.zip.blockmap
-rw-r--r--@ 1 tpetry  staff  98145371 23 Apr 14:36 StackBricks-0.3.0-arm64.dmg
-rw-r--r--  1 tpetry  staff    103144 23 Apr 14:36 StackBricks-0.3.0-arm64.dmg.blockmap
-rw-r--r--  1 tpetry  staff  94211978 23 Apr 14:36 StackBricks-0.3.0-mac.zip
-rw-r--r--  1 tpetry  staff    100450 23 Apr 14:36 StackBricks-0.3.0-mac.zip.blockmap
-rw-r--r--@ 1 tpetry  staff  95668443 23 Apr 14:36 StackBricks-0.3.0.dmg
-rw-r--r--  1 tpetry  staff    101162 23 Apr 14:36 StackBricks-0.3.0.dmg.blockmap
-rw-r--r--  1 tpetry  staff      1512 23 Apr 14:36 builder-debug.yml
-rw-r--r--  1 tpetry  staff       372 23 Apr 14:35 builder-effective-config.yaml
-rw-r--r--  1 tpetry  staff       815 23 Apr 14:36 latest-mac.yml

When changing the target mode to only build a dmg release, electron-updater failed because it's searching for a not existing zip file. Which seems to be a known bug for some time.

mmaietta commented 2 years ago

When changing the target mode to only build a dmg release, electron-updater failed because it's searching for a not existing zip file. Which seems to be a known bug for some time.

That's not a bug. If you want to use auto-update on mac, you need to build a zip. Differential dmg updates were never implemented/finished as a feature

searches for a not-existing app-update.yml

Can you confirm that you're running it with publish args? (electron-builder --publish always)

tpetry commented 2 years ago

Sure, I am executing electron-builder with the option to always publish:

electron-builder build --config .electron-builder.config.js --config.asar=false \
    --macos --x64 --arm64 --publish always

If I don't use --publish always, only the .app files are built, no latest-mac.yml, .dmg or .zip.

Is the app-update.yml really required for the auto-updater together with the latest-mac.yml? Sounds strange needing two different files. Therefore, I expected electron-updater to be wrong and not electron-publish.

vraravam commented 2 years ago

Also, if the .app file is the one that contains the app-update.yml anyways in Contents/Resources/app-update.yml, then why is it not generated when using the --dir option alone?