question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
dscalzicommented, Oct 15, 2018

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 to electron-updater-bin which points to that repo. Change any imports/requirements from electron-updater to electron-updater-bin.

When the PR is merged and released you can switch back to electron-updater.

0reactions
Pagebakerscommented, Oct 17, 2018

Thanks @dscalzi That works

If you rename the package back to electron-updater you can just run

npm install electron-updater@https://github.com/WesterosCraftCode/electron-updater-bin

Without needing to change anything in the code.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found