Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EACCES when using quitAndInstall electron 3 #3367

Closed
timotheeguerin opened this issue Oct 5, 2018 · 7 comments
Closed

EACCES when using quitAndInstall electron 3 #3367

timotheeguerin opened this issue Oct 5, 2018 · 7 comments

Comments

@timotheeguerin
Copy link
Contributor

  • 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);
    }
})
@dscalzi
Copy link

dscalzi commented Oct 6, 2018

I have the same issue with the assisted installer for NSIS. Been an issue with my app since electron 3.x was released.

image

@develar Fix would be appreciated when you can, stuck on 2.x for now.

@dscalzi
Copy link

dscalzi commented Oct 11, 2018

Do you know of any possible workaround for election 3? Looks like this won't be handled for a while.

@timotheeguerin
Copy link
Contributor Author

not that I know of, I'll probably push the compiled js to another branch of my fork if this doesn't get merged and reference it in my package.json

@ahadcove
Copy link

I actually just started receiving the same error after updating to Electron 3.0.3 from 2.x.
:(

@dscalzi
Copy link

dscalzi commented 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.

@Pagebakers
Copy link

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.

@Franco8888
Copy link

I got mine working by including the node_modules's bin folders. I use to have

"!**/node_modules/.bin"
in the files parameter in the build param in package.json.

I removed this so no it includes the bin of each of the node modules.

I also include electron-updater and all of it's dependencies in thje files parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants