EACCES when using quitAndInstall electron 3
See original GitHub issue- Version:
- Builder: 20.28.4
- Updater: 3.1.2
- Target: Windows
C:\Users\tiguerin\AppData\Roaming\BatchExplorer\__update__\BatchExplorer Setup 0.18.3-stable.99.exe EACCES
at Process.ChildProcess._handle.onexit (internal/child_process.js:229:19)
at onErrorNT (internal/child_process.js:406:16)
I believe the issue is that the spawn
command doesn’t actually throw an error that is catchable here https://github.com/electron-userland/electron-builder/blob/master/packages/electron-updater/src/NsisUpdater.ts#L115
After testing locally I think the try catch
needs to be changed to on("error"
might have been a change to node 10 vs 8
This mock code for example works fine when using .on("error"
const { spawn } = require("child_process");
const installerPath = "C:\\Users\\tiguerin\\AppData\\Roaming\\BatchExplorer\\__update__\\BatchExplorer Setup 0.18.3-stable.99.exe";
const args = [];
const spawnOptions = {
detached: true,
stdio: "ignore",
};
const elevatePath = "C:\\Program Files\\BatchExplorer\\resources\\elevate.exe";
spawn(installerPath, args, spawnOptions).on("error", (e) => {
// yes, such errors dispatched not as error event
// https://github.com/electron-userland/electron-builder/issues/1129
if ((e).code === "UNKNOWN" || (e).code === "EACCES") { // Node 8 sends errors: https://nodejs.org/dist/latest-v8.x/docs/api/errors.html#errors_common_system_errors
console.log("Access denied or UNKNOWN error code on spawn, will be executed again using elevate")
try {
spawn(elevatePath, [installerPath].concat(args), spawnOptions).unref()
} catch (e) {
console.error("Elevate failed too", e);
}
} else {
console.error("Error here", e);
}
})
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
electron auto-update on click - Stack Overflow
I think it's that electron.remote.autoUpdater.quitAndInstall() doesn't work when run in the renderer. In the docs it doesn't say anything ...
Read more >Auto Update - electron-builder
Use autoUpdater from electron-updater instead of electron : JavaScript ... An update check uses up to 3 requests per check.
Read more >4. Binaries, Installers, and Updates - Introducing Electron [Book]
Once the update is downloaded, Electron's auto-updater will install the update automatically as soon as the app quits. To do so programmatically, developers...
Read more >app | Electron
Note: If application quit was initiated by autoUpdater.quitAndInstall() , then before-quit is emitted after emitting close event on all windows and closing them ......
Read more >How to use the electron-updater.autoUpdater.quitAndInstall ...
To help you get started, we've selected a few electron-updater.autoUpdater.quitAndInstall examples, based on popular ways it is used in public projects.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve compiled @timotheeguerin’s solution to another repository. https://github.com/WesterosCraftCode/electron-updater-bin
As a temporary workaround, you can change your
electron-updater
dependency toelectron-updater-bin
which points to that repo. Change any imports/requirements fromelectron-updater
toelectron-updater-bin
.When the PR is merged and released you can switch back to
electron-updater
.Thanks @dscalzi That works
If you rename the package back to electron-updater you can just run
Without needing to change anything in the code.