electron: autoUpdater.quitAndInstall fails to relaunch on Mac OS 11 Big Sur

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

I wanted to post this in https://github.com/electron/electron/issues/24319 but the issue is locked.

Related comment with more details.

  • Electron Version:
    • v8.5.1
  • Operating System:
    • Mac OS 11 Big Sur Beta
  • Last Known Working Electron version:
    • n/a

Actual Behavior

When restarting an upgraded electron application with autoUpdater.quitAndInstall, the application quits and upgrades successfully, but is NOT relaunched thereafter.

Expected Behavior

The application should be launched after upgrading.

To Reproduce

It’s very hard for me to reproduce this issue because Squirrel.Mac requires that any MacOS app using auto-update is code-signed, and I can’t figure out how to build Squirrel from source successfully so as to artificially remove that restriction.

If there are any guides available for building Squirrel.Mac + Electron together, i would be very thankful to hear about them.

Additional Information

As mentioned here, there are two lines in the Squirrel install log normally present with earlier versions of MacOS which are missing on the Big Sur log.

2020-09-17 17:55:15.344 ShipIt[4099:100431] Application launched at file:///Applications/Whatever.app/
2020-09-17 17:55:15.344 ShipIt[4099:100431] ShipIt quitting

Those lines are logged from these locations:

https://github.com/Squirrel/Squirrel.Mac/blob/44468f858ce0d25c27bd5e674abfa104e0119738/Squirrel/ShipIt-main.m#L128 https://github.com/Squirrel/Squirrel.Mac/blob/44468f858ce0d25c27bd5e674abfa104e0119738/Squirrel/ShipIt-main.m#L145

My original plan was to add some extra logging statements in Squirrel.Mac’s source code and use that to determine why those lines are missing, but i hit a brick wall trying to build Squirrel and Electron together from lack of documentation.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 28 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Yes, that’s what I’m doing. We have a test build with a fake app version (99.99.99) that has same Electron version (11.x) as our RC. It works fine on Windows and Mac OS Catalina, but not on Big Sur. If I’m the only one with the problem, I’ll do some more digging on our side, but looks like there’s more people.

@koenoe @abmai Please confirm it’s not a BrowserWindow preventing the quit and install with something like:

function callBeforeQuitAndInstall() {
  try {
    const electron = require("electron");
    const app = electron.app;
    const BrowserWindow = electron.BrowserWindow;
    if (tray) tray = null;
    app.removeAllListeners("window-all-closed");
    var browserWindows = BrowserWindow.getAllWindows();
    browserWindows.forEach(function(browserWindow) {
      browserWindow.removeAllListeners("close");
    });
  } catch (e) {
    console.log(e);
  }
}

For the folks who don’t want to upgrade their application to electron v11 just to fix this auto-updater issue, they can simply replace the squirrel.mac pre-build binaries downloaded by electron before compiling the electron artifacts with the binary build on top of latest commit for https://github.com/Squirrel/Squirrel.Mac/commits/master ( at least work for electron v9 ). I would expect squirrel.mac to release the latest binary soon with all the fixes as their latest release is built on top of a very old commit P.S: You need to build Squirrel.mac binary with the latest Xcode versions (currently the latest version is 12.3) so as to make the workaround work on bigSur OS mentioned by @ivanggq in this comment

Still having this issue in 11.0.4. Also tried @alectrocute suggestion, no effect. Works fine on Windows.

same ^, still having this issue in Electron 11.0.3

@twitharshil Unfortunately not, it requires several build system changes that aren’t safe enough to backport

My test updating an app with Electron 11 did not work. I can see the new code in ShipIt being executed, because I see that ShipIt prints this log:

Attempting to launch app on lower than 11.0

This is the changed code in ShipIt, which checks for macOS version 11 and performs conditional launch code:

if (@available(macOS 11.0, *)) {
	NSLog(@"Attempting to launch app on 11.0 or higher");
	NSTask *task = [[NSTask alloc] init];
	[task setLaunchPath: @"/usr/bin/open"];
	[task setArguments: [NSArray arrayWithObjects: bundleURL.path, nil]];
	[task launch];
	[task waitUntilExit];
	NSLog(@"Application launched at %@", bundleURL);
} else {
	NSLog(@"Attempting to launch app on lower than 11.0");
	if (![NSWorkspace.sharedWorkspace launchApplicationAtURL:bundleURL options:NSWorkspaceLaunchDefault configuration:@{} error:&error]) {
		NSLog(@"Could not launch application at %@: %@", bundleURL, error);
		return;
	}
	NSLog(@"Application launched at %@", bundleURL);
}

The if (@available(macOS 11.0, *)) check is failing and executing the launch code that does not work on macOS 11.

Is this fix released yet? Having this problem with Electron 11.0.3

Yes, that’s what I’m doing. We have a test build with a fake app version (99.99.99) that has same Electron version (11.x) as our RC. It works fine on Windows and Mac OS Catalina, but not on Big Sur. If I’m the only one with the problem, I’ll do some more digging on our side, but looks like there’s more people.

@koenoe Greetings! Did you and your team ever determine the cause of this issue? Was it Xcode SDK-related?

Yes, we’re using a Castlabs fork and they were building with old Xcode SDK. See: https://github.com/castlabs/electron-releases/issues/86

To be clear for folks in this thread, the fix only works for updating from 11.x to 11.x, i.e. your app must already be on 11.x in order for the updater to correctly relaunch. If your users are on older Electron versions they will have to manually restart the app (the update itself worked fine). This can’t be worked around as the updater itself needed to be updated, so folks running an older updater to update to the newer version aren’t running the fix yet.

TLDR: Trying updating from 11.X to 11.X and you’ll see it work perfectly fine

Still having this issue in 11.1.0 Any idea when this will be looked at? Or do I need to create a new issue?