Skip to content

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

Closed
@PierBover

Description

@PierBover
Contributor
  • 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.

Activity

changed the title [-]Windows: autoUpdater error when running app for the first time[/-] [+]Windows: Squirrel autoUpdater error when running app for the first time[/+] on Sep 9, 2016
anaisbetts

anaisbetts commented on Sep 9, 2016

@anaisbetts
Contributor

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

PierBover

PierBover commented on Sep 9, 2016

@PierBover
ContributorAuthor

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

PierBover commented on Sep 9, 2016

@PierBover
ContributorAuthor

@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?

anaisbetts

anaisbetts commented on Sep 9, 2016

@anaisbetts
Contributor

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

PierBover commented on Sep 9, 2016

@PierBover
ContributorAuthor

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.

MarshallOfSound

MarshallOfSound commented on Sep 9, 2016

@MarshallOfSound
Member

@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

PierBover commented on Sep 9, 2016

@PierBover
ContributorAuthor

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

MarshallOfSound commented on Sep 9, 2016

@MarshallOfSound
Member

@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

PierBover commented on Sep 9, 2016

@PierBover
ContributorAuthor

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

MarshallOfSound commented on Sep 9, 2016

@MarshallOfSound
Member

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

MarshallOfSound commented on Sep 9, 2016

@MarshallOfSound
Member

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

PierBover commented on Sep 9, 2016

@PierBover
ContributorAuthor

Done: #7160

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @anaisbetts@PierBover@MarshallOfSound

        Issue actions

          Windows: Squirrel autoUpdater error when running app for the first time · Issue #7155 · electron/electron