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

Windows: Squirrel autoUpdater error when running app for the first time #7155

Closed
PierBover opened this Issue Sep 9, 2016 · 12 comments

Comments

Projects
None yet
3 participants
@PierBover
Contributor

PierBover commented Sep 9, 2016

  • Electron version: 1.3.5
  • Operating system: Windows 10

After the install process the app opens for the first time and I get this nasty JS error.

image

Sorry for the image but I haven't found a way of copying the text error.

This only happens when opening the app for the first time.

@PierBover PierBover changed the title from Windows: autoUpdater error when running app for the first time to Windows: Squirrel autoUpdater error when running app for the first time Sep 9, 2016

@paulcbetts

This comment has been minimized.

Contributor

paulcbetts commented Sep 9, 2016

Are you trying to update the app as soon as it's first installed? I bet you are :)

@PierBover

This comment has been minimized.

Contributor

PierBover commented Sep 9, 2016

I'm not sure what you mean.

AutoUpdater is called when the app starts after the 'ready' event.

Is this the way it should be done?

@PierBover

This comment has been minimized.

Contributor

PierBover commented Sep 9, 2016

@paulcbetts the docs don't explain any of this.

https://github.com/electron/electron/blob/master/docs/api/auto-updater.md

I have a function in my MAIN process that is in charge of setting up autoUpdate.

app.on('ready', ()=>{
    initUpdates()
})

And then:

function initUpdates(){
    let platform = os.platform() + '_' + os.arch();
    let version = app.getVersion();

    autoUpdater.setFeedURL('https://domain.com/' + platform + '/' + version);

    autoUpdater.on('checking-for-update', () => {
        ...
    });

    autoUpdater.on('update-available', () => {
        ...
    });

    autoUpdater.on('update-not-available', () => {
        ...
    });

    autoUpdater.on('update-downloaded', () => {
        ...
    });

    autoUpdater.checkForUpdates();
}

Of course this happens every time the app starts.

What am I doing wrong?

@paulcbetts

This comment has been minimized.

Contributor

paulcbetts commented Sep 9, 2016

What am I doing wrong?

The error message says exactly what's happening - "Couldn't acquire update lock, is another instance running?"

The other instance is the Squirrel.Windows that is just finishing up installing your app - we launch your EXE on First Run, then exit, but if you jump on checking for updates the second you start up, Squirrel is still running.

The fix is to not check for updates when --squirrel-firstrun is in the arguments

@PierBover

This comment has been minimized.

Contributor

PierBover commented Sep 9, 2016

Thanks for the clarification.

we launch your EXE on First Run, then exit

Why do you do that?

And how come this isn't explained in any of the autoUpdater docs?

I will try to clarify this on the docs and do a PR.

@PierBover PierBover closed this Sep 9, 2016

@MarshallOfSound

This comment has been minimized.

Member

MarshallOfSound commented Sep 9, 2016

@PierBover

And how come this isn't explained in any of the autoUpdater docs?

This is in the docs for the windows-installer module

See: https://github.com/electron/windows-installer#handling-squirrel-events

@PierBover

This comment has been minimized.

Contributor

PierBover commented Sep 9, 2016

Yes but when reading the autoUpdater docs or the electron-builder docs there is mention about this.

You really can't expect your users to go read all the docs of all the dependencies for something as critical as this.

@MarshallOfSound

This comment has been minimized.

Member

MarshallOfSound commented Sep 9, 2016

@PierBover If electron-builder doesn't document it, it shouldn't end up in the Electron docs it should be documented on that repo. This functionality is independent of the autoUpdater module inside Electron 👍

electron-builder wraps / uses the electron-winstaller module (where it is documented correctly)

@PierBover

This comment has been minimized.

Contributor

PierBover commented Sep 9, 2016

This functionality is independent of the autoUpdater module inside Electron

Technically you are right, but you do offer links to the servers for example, no?

Since the autoUpdater docs are the first thing a user sees when trying to implement updates at least a mention wouldn't really hurt. Or at least you could offer a guide in your website where all this info is mentioned.

Will you accept a PR if I try to clarify all this?

@MarshallOfSound

This comment has been minimized.

Member

MarshallOfSound commented Sep 9, 2016

Will you accept a PR if I try to clarify all this?

Not for me to decide, but IMO this is a very specific use case. In order for a user to implement auto updates they will either have to:

  • Read the Squirrel.Windows docs and figure it out themselves
  • Read the electron-winstaller docs and implement that module
  • Use electron-builder which does everything for you

The first two use cases have their own documentation which explains how everything works. The third one (your use case) does not have documentation or links to the relevant electron-winstaller documentation so personally I think it should be documented there.

@MarshallOfSound

This comment has been minimized.

Member

MarshallOfSound commented Sep 9, 2016

Although considering the amount of

Platform Specific Notices

I guess it couldn't hurt to put it here https://github.com/electron/electron/blob/master/docs/api/auto-updater.md#windows as a small note and a link to the electron-winstaller docs

@PierBover

This comment has been minimized.

Contributor

PierBover commented Sep 9, 2016

Done: #7160

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