electron-builder: The command is disabled and cannot be executed at MacUpdater.quitAndInstall

  • Electron Version:^12.0.2
  • Electron-builder:^22.10.5
  • Electron-updater:^4.3.8
  • Target: Mac

  • NPM Version: 6.14.11

  • Node Version: v14.16.0

windows auto update work perfectly, but on Mac, when the application has finished updating, this error appears twice beaf8381-4a90-4d37-99d7-880b917aa21f

and once I hit ok, the app reopen itself and complete the update. How can I get rid of this macUpdater issue? I am new to electron and any help would be appreciated, Thanks.

code:

autoUpdater.on('update-downloaded', () => {
  const options = {
    buttons: [],
    title: i18n.translate('updateRelaunchRequired'),
    message: i18n.translate('updateWillRestart'),
  };

  dialog.showMessageBox(options).then(
    (result) => {
      setImmediate(() => autoUpdater.quitAndInstall(false, true));
    },
    (error) => {
      main.log(`autoUpdater.on  showMessageBox error`, error);
    }
  );
});

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 4
  • Comments: 38

Commits related to this issue

Most upvoted comments

I get the same error

  • electron-builder: 22.11.7
  • electron-updater: 4.3.9
[2021-06-24 11:05:50.258] [error] Error: Error: The command is disabled and cannot be executed
    at MacUpdater.quitAndInstall (/Applications/APP.app/Contents/Resources/app.asar/node_modules/electron-updater/out/MacUpdater.js:135:32)
    at Immediate._onImmediate (/Applications/APP.app/Contents/Resources/app.asar/app/updater.js:22:36)
    at processImmediate (internal/timers.js:456:21)

This error occur 2 times.

UPDATE:

Okay, so the problem is actually in the quitAndInstall() method.

If I update the. node_modules/electron-updater/out/MacUpdater.js:135 to not include the extra check. The updater install the updates and restart the app with the new version.

            // And trigger the update
            //this.nativeUpdater.checkForUpdates();

@mmaietta I’ve started seeing this issue recently, and it’s sporadic. Some more details in case it helps debug:

Versions of packages:

electron 12.0.2
electron-builder 22.10.5

The code that triggers the auto-update quit and install:

import { autoUpdater } from 'electron-updater';

autoUpdater.on('update-downloaded', () => {
  dialog
    .showMessageBox(mainWindow, {
      title: 'Update',
      message: 'A new version is available.',
      defaultId: 0,
      cancelId: 1,
      buttons: ['Install and restart', 'Install on next open'],
    })
    .then((result) => {
      if (result.response === 0) {
        setImmediate(() => autoUpdater.quitAndInstall());
      }
      return result.response;
    })
    .catch((err) => {
      console.log(err);
    });
});

The observed error from user perspective is that the “Update: A new version is available” dialog appears multiple times and clicking on it more than once causes the application to crash. The update ends up being installed successfully, but it’s not a great user experience. The error is also not consistent - only some users have reported this, though the frequency went up recently

The observed error from stack trace:

The command is disabled and cannot be executed

Debugging is tricky because the error is sporadic and cannot be reproduced locally 100% of the time. If I ship a fix that causes the updates to stop getting installed, then some users get kicked out of the update flow permanently. Trying to work on a 100% local repro, but no luck so far.