【问题标题】:Electron Updater downloads the update but does not install it on macOS (Squirrel.Mac)Electron Updater 下载更新但不在 macOS (Squirrel.Mac) 上安装它
【发布时间】:2023-01-11 05:35:31
【问题描述】:

我有一个跨平台的电子应用程序,我将其部署并发布到 Github。我使用 electron-updater 库实现了自己的自动更新逻辑。它在 Windows 上很有用,但是在 macOS 上有点问题。我成功地签署并公证了该应用程序,并确定问题与该部分无关。

  • macOS 版本:Ventura 13.1
  • 电子版:21.3.0
  • 电子生成器:23.6.0
  • 电子更新程序:5.3.0
  • 节点版本:19.0.1

我的应用程序照常启动,在收到更新下载事件时通知用户更新,并提示用户是否要更新应用程序。如果用户单击安装和重新启动,应用程序将调用 quitAndInstall() 函数,该函数什么也不做。它既不退出应用程序,也不重新启动它。此外,当我手动重新启动应用程序时,它会再次通知并提示用户。就这样一直持续下去。

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();
      }
    });
});

我检查了自动更新日志,发现最新的更新已下载到我的机器上。然而,不知何故,它并没有被旧版本取代。当我重新启动应用程序时,会再次记录下面的同一组日志。我试图等待最后记录的步​​骤完成,但它似乎一直停在那里直到时间结束。我的自动更新程序日志如下:

[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

我怀疑这个问题可能是由于新的 macOS Ventura 而发生的,但是,在 macOS Monterey 上的行为是相同的。我的构建配置:

"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
           }
         }
       }
    }

我期待着任何建议。希望来自遇到我正在尝试处理的相同问题的人。

我尝试了互联网上存在的所有建议解决方案,但我找不到出路。

【问题讨论】:

    标签: node.js macos electron auto-update electron-updater


    【解决方案1】:

    我解决了这个问题。在我的案例中,这是一个只读文件权限错误。我可以建议的是检查 ShipIt 的日志。它位于/Users/[xxx]/Library/Caches/[your_application_id].ShipIt/ShipIt_stderr.log。解决权限问题并没有解决 quitAndInstall 函数不起作用的问题。我为此所做的是根据文档将对话框代码更改为。我认为新版本遵循了 Promise 模式。

    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();
        }
    });
    

    如果有人面临同样的问题,希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 2019-06-08
      • 1970-01-01
      • 2020-01-27
      • 2017-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多