Home > Blockchain >  Electron Updater downloads the update but does not install it on macOS (Squirrel.Mac)
Electron Updater downloads the update but does not install it on macOS (Squirrel.Mac)

Time:01-11

I have a cross-platform Electron App, which I deploy and release to Github. I implemented an auto-update logic of my own with the electron-updater library. It works as a charm on Windows, however, it is a little bit problematic on macOS. I signed and notarized the app successfully and am sure that the problem is not related to that part.

  • macOS version: Ventura 13.1
  • Electron version: 21.3.0
  • Electron-builder: 23.6.0
  • Electron-updater: 5.3.0
  • Node version: 19.0.1

My application starts as usual, notifies the user about the update when update-downloaded event is received, and prompts the user whether they want to update the application. If the user clicks on install&restart, the application calls the quitAndInstall() function, which does nothing. Neither it quits the application, nor restarts it. Also, when I restart the application manually, it notifies and prompts the user again. And this goes on and on like that.

autoUpdater.checkForUpdatesAndNotify();
autoUpdater.on('update-downloaded', (info) => {
    // Show a dialog asking the user if they want to restart the app to install the update
    dialog.showMessageBox({
      type: 'question',
      buttons: ['Install and Restart', 'Later'],
      defaultId: 0,
      message: 'A new update has been downloaded. Would you like to install and restart the app now?'
    }, (response) => {
      if (response === 0) {
        // User clicked 'Install and Restart'
        autoUpdater.quitAndInstall();
      }
    });
});

I checked the auto-updater logs, and see that the latest update is downloaded to my machine. However, somehow, it is not being replaced with the old version. When I restart the application, the same set of logs below are logged again. I tried to wait for the last logged step to complete, but it seems like it is stuck there until the end of time. My auto-updater logs are as follows:

[2023-01-08 11:37:05.284] [info]  Checking for update
[2023-01-08 11:37:06.789] [info]  Found version 1.0.8 (url: Duolance-Tracker-1.0.8-mac.zip, Duolance-Tracker-1.0.8.dmg)
[2023-01-08 11:37:06.791] [info]  Downloading update from Duolance-Tracker-1.0.8-mac.zip, Duolance-Tracker-1.0.8.dmg
[2023-01-08 11:37:06.796] [warn]  sysctl shell command to check for macOS Rosetta environment failed: Error: Command failed: sysctl sysctl.proc_translated
sysctl: unknown oid 'sysctl.proc_translated'

[2023-01-08 11:37:06.800] [info]  Checked 'uname -a': arm64=false
[2023-01-08 11:37:07.162] [info]  Update has already been downloaded to /Users/ardaakcabuyuk/Library/Application Support/Caches/duolancetracker-updater/pending/Duolance-Tracker-1.0.8-mac.zip).
[2023-01-08 11:37:10.983] [info]  / requested
[2023-01-08 11:37:10.988] [info]  /3cd1718f82c50e8105236129abe5fcfac9263b740235c99b2b23bc22cfd581c9d49d1e30dbbb897397f626e45c20d0fda5dc02336633b6cabf7214322e322714.zip requested
[2023-01-08 11:37:10.989] [info]  /3cd1718f82c50e8105236129abe5fcfac9263b740235c99b2b23bc22cfd581c9d49d1e30dbbb897397f626e45c20d0fda5dc02336633b6cabf7214322e322714.zip requested by Squirrel.Mac, pipe /Users/ardaakcabuyuk/Library/Application Support/Caches/duolancetracker-updater/pending/Duolance-Tracker-1.0.8-mac.zip

I suspected that this issue might be occurring because of the new macOS Ventura, however, the behavior is the same on macOS Monterey. My build configuration:

"mac": {
      "asarUnpack": "**/*.node",
      "category": "public.app-category.productivity",
      "target": [
        "default"
      ],
      "icon": "build/icon.icns",
      "entitlements": "build/sign/entitlements.mac.plist",
      "entitlementsInherit": "build/sign/entitlements.mac.plist",
      "hardenedRuntime": true,
      "gatekeeperAssess": false,
      "extendInfo": {
        "NSAppTransportSecurity": {
           "NSAllowsArbitraryLoads": true
         },
         "NSExceptionDomains": {
           "localhost": {
             "NSTemporaryExceptionAllowsInsecureHTTPSLoads": false,
             "NSIncludesSubdomains": false,
             "NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
             "NSTemporaryExceptionMinimumTLSVersion": "1.0",
             "NSTemporaryExceptionRequiresForwardSecrecy": false
           }
         }
       }
    }

I'm looking forward for any suggestions. Hopefully from someone that suffered from the same problem I am trying to deal with.

I tried every suggested solution existent on the Internet, however I couldn't find the way out.

CodePudding user response:

I solved the issue. It was a read-only file permission error in my case. What I can suggest is to check the logs of ShipIt. It is located at /Users/[xxx]/Library/Caches/[your_application_id].ShipIt/ShipIt_stderr.log. Resolving the permission issue did not fix the quitAndInstall function not working. What I did for that is to change the dialog code to according to the documentation. The new version, I think, follows the Promise pattern.

dialog.showMessageBox({
    type: 'question',
    buttons: ['Install and Restart', 'Later'],
    defaultId: 0,
    message: 'A new update has been downloaded. Would you like to install and restart the app now?'
}).then(selection => {
    if (selection.response === 0) {
        // User clicked 'Install and Restart'
        autoUpdater.quitAndInstall();
    }
});

Hope this helps if someone is facing the same issue.

  • Related