英文:
Electron Updater downloads the update but does not install it on macOS (Squirrel.Mac)
问题
我有一个跨平台的Electron应用程序,我将其部署并发布到GitHub。我使用electron-updater库实现了自己的自动更新逻辑。在Windows上它运行得很好,但在macOS上有点问题。我已经成功地签名和验证了应用程序,确保问题与签名部分无关。
- macOS版本:Ventura 13.1
- Electron版本:21.3.0
- Electron-builder:23.6.0
- Electron-updater:5.3.0
- Node版本:19.0.1
我的应用程序像往常一样启动,在接收到update-downloaded事件时通知用户,并提示用户是否要更新应用程序。如果用户点击“安装并重新启动”,应用程序会调用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
}
}
}
}
我期待任何建议。希望有人能够帮助我解决这个问题,希望能找到与我面临的相同问题的人。
我尝试了互联网上的每个建议的解决方案,但都找不到出路。
英文:
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.
答案1
得分: 1
我解决了这个问题。在我的情况下,它是一个只读文件权限错误。我可以建议的是检查ShipIt的日志。它位于/Users/[xxx]/Library/Caches/[your_application_id].ShipIt/ShipIt_stderr.log
。解决权限问题并没有解决quitAndInstall
函数不工作的问题。为此,我根据文档更改了对话框代码。我认为新版本遵循了Promise模式。
dialog.showMessageBox({
type: 'question',
buttons: ['安装并重启', '稍后'],
defaultId: 0,
message: '已下载新更新。您想现在安装并重启应用程序吗?'
}).then(selection => {
if (selection.response === 0) {
// 用户点击了'安装并重启'
autoUpdater.quitAndInstall();
}
});
希望这能帮助面临相同问题的人。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论