Electron Updater下载更新,但没有在macOS (Squirrel.Mac)上安装 &



我有一个跨平台的电子应用程序,我部署并发布到Github。我用电子更新程序库实现了我自己的自动更新逻辑。它在Windows上很有魅力,但是在macOS上就有点问题了。我已经成功地对app进行了签名和公证,我确信问题与该部分无关。

  • macOS version: Ventura 13.1
  • 电子版:21.3.0
  • Electron-builder: 23.6.0
  • Electron-updater: 5.3.0
  • 节点版本:19.0.1

我的应用程序照常启动,当收到update-download事件时通知用户更新,并提示用户是否要更新应用程序。如果用户单击install&restart,则应用程序调用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
}
}
}
}

我期待你的建议。

我尝试了网上所有建议的解决方法,但我就是找不到出路。

我解决了问题。在我的情况下,这是一个只读文件权限错误。我的建议是查看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();
}
});

希望这有助于如果有人面临同样的问题。

最新更新