electron-builder: autoupdater.quitAndInstall don't relaunch and update success

  • electron-builder: 20.28.4
  • electron-updater: 3.1.2
  • Target: Mac

click Restart now can relaunch because of app.relaunch();app.exit(), but cant update from the downloaded update file. Then will launch app and show dialog again and so on, repeated cycle. @develar @maczikasz, thx.

index = dialog.showMessageBox({
          type: 'info',
          buttons: ['Restart now', 'later'],
          title: 'Updates downloaded',
          message: Message.downloaded + meta.version,
          detail: meta.readme,
        });
        if (index === 0) {
          try {
            autoUpdater.quitAndInstall();
            setTimeout(() => {
              app.relaunch();
              app.exit(0);
            }, 6000);
          } catch (e) {
            dialog.showErrorBox('Error', 'Failed to install updates');
          }
        }
      } else {
        delFile(pkgCacheDir);
        dialog.showMessageBox({
          type: 'warning',
          buttons: ['OK'],
          title: 'Updates downloaded fail',
          message: global.localizedStrings.pkgSignFailMessage,
          detail: global.localizedStrings.pkgSignFailDetail,
        });
      }

Error:

[2018-10-19 00:02:55:0774] [error] Error: Error: No update available, can't quit and install
    at MacUpdater.quitAndInstall (/Users/cuitfanshide/Documents/Projects/7-dragon-ball-wallet-2c/dist/mac/WOOKONG Solo.app/Contents/Resources/app/node_modules/electron-updater/src/MacUpdater.ts:149:24)
    at /Users/cuitfanshide/Documents/Projects/7-dragon-ball-wallet-2c/dist/mac/WOOKONG Solo.app/Contents/Resources/app/dist/main.js:910:43
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:109:7)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 26 (2 by maintainers)

Most upvoted comments

Why was this issue closed? Any fixes found?

still doesn’t work in electron-updater@4.3.5 on macos 10.15.7

The exit and update were successful, but there was no restart

I’m seeing the same thing. Same versions.

you can use electron-updater-debug@1.0.0,then you can very probably reboot. I support you write code as bellow:

setTimeout(() => {
  autoUpdater.quitAndInstall();
}, 6000);

This is what I maintain, just created, because the project time is so urgent, there is no time to specification this package.

In my case I just fu**ed up with

win.on('close', event => {

}

I prevent it to close the app properly by calling event.preventDefault();

so in the end it was a mistake with my code rather than Electron

If anyone is still stumbling with this issue (at least on Windows), check if you’re not setting closable: false on options passed to new BrowserWindow(opts).

try {
            autoUpdater.quitAndInstall();
            setTimeout(() => {
              app.relaunch();
              app.exit(0);
            }, 6000);
          } catch (e) {
            dialog.showErrorBox('Error', 'Failed to install updates');
          }

This code is not correct.

setImmediate(() => {
  autoUpdater.quitAndInstall();
})

is enough — you need to wrap quitAndInstall in setImmediate if called from dialog. And no need to call relaunch/exit.

Also, please use latest released versions of electron-updater/electron-builder/electron — number of possible issues are fixed now.

it works!

try {
            autoUpdater.quitAndInstall();
            setTimeout(() => {
              app.relaunch();
              app.exit(0);
            }, 6000);
          } catch (e) {
            dialog.showErrorBox('Error', 'Failed to install updates');
          }

This code is not correct.

setImmediate(() => {
  autoUpdater.quitAndInstall();
})

is enough — you need to wrap quitAndInstall in setImmediate if called from dialog. And no need to call relaunch/exit.

Also, please use latest released versions of electron-updater/electron-builder/electron — number of possible issues are fixed now.

I’m using electron ^9.1.1, electron-builder ^22.7.0, electron-updater ^4.3.5, and my app isn’t restarting after an update on OSX. It works fine on Windows.

I’ve removed all exit handlers app.on(‘window-all-closed’) and app.on(‘before-quit’) just in case they were messing with shutdown, but no luck. I should also mention that it had been working, but just stopped working recently. Not sure what happened. The code I’m using is

  autoUpdater.on('update-downloaded', () => {
    autoUpdater.quitAndInstall(true, true);
  });

Are there any new solutions/suggestions? Thanks!