atom icon indicating copy to clipboard operation
atom copied to clipboard

Linux: Atom Silently Quits when Packages, Command Palette, Toggle, Application:Install Update is clicked

Open DAC324 opened this issue 3 years ago • 2 comments

Hello all,

Atom just quits without an error message after the following steps:

  1. Start Atom
  2. In the menu, go to Packages, Command Palette Toggle.
  3. Enter install as a search term
  4. Choose and click Application: Install Update

And no, this does not appear to be specific to Arch Linux as it happens with the binary package downloadable from Azure as per Readme.md, as well. Amendment The same error happens with the Debian package downloadable from Azure, on a Debian based Linux system.

DAC324 avatar Jun 22 '22 20:06 DAC324

Update: I investigated the code a little bit and encountered the following: That behavior of atom closing after having selected Packages->Command Palette->Toggle->(search for install and select) Application: Install Update is actually not a crash but atom silently quitting, because of the following code:

    this.on('application:install-update', () => {
     this.quitting = true;
     this.quittingForUpdate = true;
     this.autoUpdateManager.install();
    });

That line

this.autoUpdateManager.install();

actually seems to do nothing but simply quit the editor. Why?

this.autoUpdateManager.install();

calls

  install() {
    if (!this.testMode) autoUpdater.quitAndInstall();
  }

where autoupdater is calling electron itself:

  initialize() {
    if (process.platform === 'win32') {
      const archSuffix = process.arch === 'ia32' ? '' : `-${process.arch}`;
      this.feedUrl =
        this.updateUrlPrefix +
        `/api/updates${archSuffix}?version=${this.version}&os_version=${
          os.release
        }`;
      autoUpdater = require('./auto-updater-win32');
    } else {
      this.feedUrl =
        this.updateUrlPrefix +
        `/api/updates?version=${this.version}&os_version=${os.release}`;
      ({ autoUpdater } = require('electron'));
    }

Indeed, that's not very elegant to simply quit because auto updates do not seem to be supported on Linux

    switch (process.platform) {
      case 'win32':
        if (!autoUpdater.supportsUpdates()) {
          this.setState(UnsupportedState);
        }
        break;
      case 'linux':
        this.setState(UnsupportedState);
    }

but that's the way it's actually implemented :(

Would be a lot better to simply alert() that this feature is not yet implemented on Linux, instead of simply quitting the whole program.

DAC324 avatar Jun 27 '22 10:06 DAC324

Here's a patch that exactly achieves this. Instead of simply quitting atom on Linux when Packages->Command Palette->Toggle->(search for install and select) Application: Install Update is clicked, there is a dialog indicating that this feature is not yet supported on Linux:

--- a/src/main-process/auto-update-manager.js	2022-06-24 18:26:06.425993344 +0200
+++ b/src/main-process/auto-update-manager.js	2022-06-27 12:41:17.818911759 +0200
@@ -162,7 +162,22 @@
   }
 
   install() {
-    if (!this.testMode) autoUpdater.quitAndInstall();
+    if (process.platform === 'win32') {
+        if (!this.testMode) autoUpdater.quitAndInstall();
+    }
+    else
+    {
+        const { dialog } = require('electron');
+        dialog.showMessageBox({
+           type: 'info',
+           buttons: ['OK'],
+           icon: this.iconPath,
+           message: 'This feature is not supported on your platform.',
+           title: 'No Update Available',
+           detail: `Automatic update download and installation not yet supported.`
+        });
+    }
+
   }
 
   onUpdateNotAvailable() {

DAC324 avatar Jun 27 '22 10:06 DAC324