Lilian Bideau
Lilian Bideau

Reputation: 307

electron updater notify for new release but do not update or download new release in windows

electron updater 4.2.0 package do not download new release but can detect it

This is a private repository on github

new releases successfully send to github

release github

In package.json:

"build": {
"appId": "com.myApp.ID",
"npmRebuild": false,
"win": {
  "icon": "./resources/electron/icons/256x256.png",
  "publish": [
    {
      "provider": "github",
      "owner": "me",
      "repo": "POS",
      "private": true,
      "releaseType": "release",
      "token": "<private token>"
    }
  ],
  "target": [
    {
      "target": "nsis",
      "arch": [
        "x64"
      ]
    }
  ]
}
},

my electron.js file or main.js I have :

  win.webContents.on('did-finish-load', () => {
    if(!serve) {
      appUpdater(win);
    }
  });

appUpdater function is:

function appUpdater(win) {
  autoUpdater.autoInstallOnAppQuit = true;
  autoUpdater.autoDownload = true;
  autoUpdater.logger = logger;
  /* Log whats happening
  TODO send autoUpdater events to renderer so that we could console log it in developer tools
  You could alsoe use nslog or other logging to see what's happening */
  let foundUpdate = false;
  autoUpdater.on('checking-for-update', () => {
    dialog.showMessageBox(win, {
      message: 'CHECKING FOR UPDATES !!'
    });
  });
  autoUpdater.on('update-available', () => {
    foundUpdate = true;
    dialog.showMessageBox(win, {
      message: ' update-available !!'
    });
  });
  autoUpdater.on('error', error => {
    autoUpdater.logger.debug(error);
  });
  // Ask the user if update is available
  autoUpdater.on('update-downloaded', (_event, releaseNotes, _releaseName) => {
    let message = 'A new version is now available. It will be installed the next time you restart the application.';
    dialog.showMessageBox(win, {
      type: 'question',
      buttons: ['Install', 'Later'],
      defaultId: 0,
      message: 'A new version has been downloaded',
      detail: message
    }, response => {
      if(response === 0) {
        setTimeout(() => autoUpdater.quitAndInstall(), 1);
      }
    });
  });
  // init for updates
  setInterval(() => {
    if(!foundUpdate) {
      autoUpdater.checkForUpdates();
    }
  }, 60000);
}
exports.appUpdater = appUpdater;

I get documented from auto updater

Auto-updatable Targets is windows nsis

checking-for-update and update-available event fire correctly but update-downloaded or error simply does not fire

Please if you already have experience on this let me know

note: I set environment variable GH_TOKEN in the user machine too

Upvotes: 5

Views: 5453

Answers (2)

stephaneb
stephaneb

Reputation: 167

Same problem with some specifics versions of electron-builder and electron-updater.For me, it works with exactly:

"electron-builder": "22.11.7"
"electron-updater": "4.3.8"

But for instance, it does not work anymore with electron-updater 4.3.9 ...

Upvotes: 1

Lilian Bideau
Lilian Bideau

Reputation: 307

Better now than never I was struggling with the new update of mac bigSur as electron-builder@^20.38.0 was giving me very bad errors!!! So I decided to update to the latest version

electron: ^12.0.2
electron-builder: ^22.10.5
electron-updater: ^4.3.8

It was not working at first giving me error like: Cannot download differentially, fallback to full download: Error: Maximum allowed size is 50 MB.

At last my version of node was v10.15.1 locally I updated to v14.16.0 now it works!

Another issue using other versions update and downgrade it was downloading it but failed on install.

Upvotes: 1

Related Questions