Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac downloads the update, but does not install it #6058

Open
alfredsgenkins opened this issue Jul 14, 2021 · 16 comments
Open

Mac downloads the update, but does not install it #6058

alfredsgenkins opened this issue Jul 14, 2021 · 16 comments

Comments

@alfredsgenkins
Copy link

  • Electron-Builder Version: ^22.10.5
  • Node Version: v14.17.0
  • Electron Version: ^11.0.1
  • Electron Type (current, beta, nightly): current
  • Target: dmg

Hey!

This issue is similar by description to #2317, but I have not found any answers there. I decided to open new issue and provide more background.

My application on Mac shows the following notification:

Screenshot 2021-07-14 at 16 23 34

But once I close and reopen the app back nothing happens. The old version is still displayed. I also want my application use the quitAndInstall pattern. For me the fact the the notification is displayed in the first place is strange.

The background:

  • I have configured automatic updates for my application
  • I have made my application notarized by apple
  • I want to use quitAndInstall, I have ensure the safe exit
  • I am using Private GitHub repository to store releases
  • Autoupdate on Linux AppImage works

How my application handles an update:

import { app, BrowserWindow, shell } from 'electron';
import { autoUpdater } from 'electron-updater';
import log from 'electron-log';

function ensureSafeQuitAndInstall() {
  app.removeAllListeners('window-all-closed');
  const browserWindows = BrowserWindow.getAllWindows();
  browserWindows.forEach((browserWindow) => {
    browserWindow.removeAllListeners('close');
  });
  autoUpdater.quitAndInstall(false);
}

export default class AppUpdater {
  constructor() {
    log.transports.file.level = 'info';
    autoUpdater.logger = log;
    autoUpdater.checkForUpdatesAndNotify();

    autoUpdater.on('update-downloaded', () => {
      setImmediate(ensureSafeQuitAndInstall);
    });
  }
}

I took the code sample from this issue and built my implementation on top if it: #1604

Why I think the signature is fine:

Screenshot 2021-07-14 at 16 32 21

Despite me expecting the signature with the Developer ID, the app only shows notarization and hardening. Not sure why. The app however, only promts the this on first install, thus I assume it is OK:

Screenshot 2021-07-14 at 16 36 28

How I sign my app:

I used following configuration in package.json:

  ...
  "afterSign": ".erb/scripts/Notarize.js",
  "mac": {
    ...
    "target": [
      "dmg"
    ],
    "asarUnpack": "**/*.node",
    "type": "distribution",
    "hardenedRuntime" : true,
    "gatekeeperAssess": false,
    "entitlements": "assets/entitlements.mac.plist",
    "entitlementsInherit": "assets/entitlements.mac.plist",
    "icon": "assets/icons/mac/icon.icns",
    "provisioningProfile": "assets/preflight_provision_profile.provisionprofile"
  },
  ...

My notarization script is using electron-notarize and I sign it with following code:

const { notarize } = require('electron-notarize');
const { build } = require('../../package.json');

exports.default = async function notarizeMacos(context) {
  const { electronPlatformName, appOutDir } = context;
  const appName = context.packager.appInfo.productFilename;
  
  await notarize({
    appBundleId: build.appId,
    appPath: `${appOutDir}/${appName}.app`,
    appleId: process.env.APPLE_ID,
    appleIdPassword: process.env.APPLE_ID_PASS,
    ascProvider: process.env.APPLE_PROVIDER_ID,
  });
};

I build my app using following command:

CSC_LINK="XXX" \
CSC_KEY_PASSWORD=XXX \
APPLE_ID="XXX" \
APPLE_ID_PASS="XXX" \
APPLE_PROVIDER_ID="XXX" \
yarn electron-builder build -mwl --publish always

What I also suspect:

The react boilerplate I use, contained the following code:

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit();
  }
});

I heared that this could prevent app from closing. But I call app.removeAllListeners('window-all-closed') thus this should not be the case.

In logs, I see following message (relating me to #486, but again, this appears to not break anything):

[XXX] [warn] Error: ditto: Couldn't read PKZip signature
[XXX] [error] Error: Error: ditto: Couldn't read PKZip signature

Any ideas, suggestions?

@mmaietta
Copy link
Collaborator

That may have been resolved through #5802
Please try latest electron-builder at 22.11.9

@cuantmac
Copy link

That may have been resolved through #5802
Please try latest electron-builder at 22.11.9

nothing happend

@stale
Copy link

stale bot commented Oct 2, 2021

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the backlog label Oct 2, 2021
@vraravam
Copy link

vraravam commented Oct 2, 2021

I'm on v22.12.1 - same case (nothing fixed)

@stale stale bot removed the backlog label Oct 2, 2021
@Nokel81
Copy link
Contributor

Nokel81 commented Oct 27, 2021

We are using [email protected] and [email protected] and on macos we get the following logs:

Found version 5.3.0-alpha.6.20211026.3
Downloading update from ...
sysctl shell command to check for macOS Rosetta environment failed: Error: Command failed: sysctl sysctl.proc_translated
Update has already been downloaded to

And then I have a log line:

[UPDATE-CHECKER]: User chose to update now

from the following code

logger.info(`${AutoUpdateLogPrefix}: User chose to update now`);
setImmediate(() => {
	  app.removeAllListeners("window-all-closed");
	  WindowManager.getInstance().destroy();
	  autoUpdater.quitAndInstall(true, true);
});

And the windows close (because we are destroying them due to testing) but the quitAndInstall() call doesn't do anything.

I am on macOS 10.15.7

@jmeinke
Copy link
Contributor

jmeinke commented Dec 8, 2021

We can confirm this issue. It might have something to do with missing administration privileges for being able to update the application. After entering user credentials for allowing the update of the app, then executing the update again it works.

@nicograef
Copy link

@Nokel81 Is this a connected (or the same) bug that you fixed with #6390 ?
Thanks!

@Nokel81
Copy link
Contributor

Nokel81 commented Dec 16, 2021

@nicograef It might be. I have not had this problem since using that fix I provided.

@theolivenbaum
Copy link

We're seeing the same issue on our app. Update is downloaded, but never installed. Used to work before until recently.

@Nokel81
Copy link
Contributor

Nokel81 commented Dec 16, 2021

@theolivenbaum Are you using [email protected]?

@theolivenbaum
Copy link

Seems like 4.6.1 https://github.com/theolivenbaum/Electron.NET/blob/21427f0b449ba8e4d37e02b037685bb5e9a4d323/ElectronNET.Host/package-lock.json#L411

Was this fixed on 4.6.2? If so I'll give it a try tomorrow!

@Nokel81
Copy link
Contributor

Nokel81 commented Dec 16, 2021

Yes, my PR was included in 4.6.2 according to the comment posted onto it

@helious
Copy link

helious commented Feb 27, 2022

@alfredsgenkins I think I've figured this out.. after stumbling around the myriad threads on this issue, it's a simple configuration setting 😆 (https://www.electron.build/configuration/mac#MacConfiguration-target)

so just doing this:

"mac": {
    ...
    "target": [
      "default"
    ],

as the the auto updater relies on the .zip, just having "dmg" there won't sign the .zip; but "default" signs the .dmg and .zip.

the logs were able to point me in the right direction:

[2022-02-27 13:55:15.447] [info] Found version 0.0.1 (url: app-0.0.1.dmg)
[2022-02-27 13:55:15.448] [info] Downloading update from app-0.0.1.dmg
[2022-02-27 13:55:15.637] [info] Update has already been downloaded to /Users/user/Library/Application Support/Caches/app-updater/pending/update.zip).
[2022-02-27 13:55:15.657] [info] / requested
[2022-02-27 13:55:15.661] [info] /1645988115637-3819.zip requested
[2022-02-27 13:55:15.661] [info] /1645988115637-3819.zip requested by Squirrel.Mac, pipe /Users/user/Library/Application Support/Caches/app-updater/pending/update.zip
[2022-02-27 13:55:15.945] [warn] Error: ditto: Couldn't read PKZip signature
[2022-02-27 13:55:15.946] [error] Error: Error: ditto: Couldn't read PKZip signature

@stale
Copy link

stale bot commented Apr 29, 2022

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the backlog label Apr 29, 2022
@stale stale bot removed the backlog label May 17, 2022
@amin-wan-kenobi
Copy link

amin-wan-kenobi commented May 18, 2022

Hi Everyone,
I had the same issue in MacOS and I managed to solve it.
Below is the code which was not working.
autoUpdater.on("update-downloaded", updateInfo => { autoUpdater.quitAndInstall(); })
It closed the app but it never relaunched it. So I checked both log files of the electron app as well as the ShipIt and I realized that the moment the download is done, it would send a request to install the new application (even if you don't call the quitAndInstall method).
So to fix the issue, I just exited the app with a bit of a delay as it seems there is some sort of race issue here.
autoUpdater.on("update-downloaded", updateInfo => { setTimeout(() => { autoUpdater.quitAndInstall(); app.exit(); }, 10000); })
I checked the logs in ShipIt at the same time and I saw that it began the installation process and right after it relaunched the app. So if you're on mac, try to exit (not quit) after the download is done. Mine works now.
I hope it helps.

@liangskyli
Copy link

I also have the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests