Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have my own server where I uploaded app installer via FTP. Its name is quickmargo Setup 1.0.0.exe and it's available at

https://quickmargo.pl/dist/download/quickmargo Setup 1.0.0.exe

Also via FTP I uploaded latest.yml to same directory and it is available at

https://quickmargo.pl/dist/download/latest.yml

In my project in index.js I have

import { autoUpdater } from 'electron-updater'
autoUpdater.setFeedURL('https://quickmargo.pl/dist/download');
autoUpdater.on('update-downloaded', () => {
    autoUpdater.quitAndInstall()
autoUpdater.on('update-available', (ev, info) => {
    alert('Update required!');
app.on('ready', async () => {
    if (process.env.NODE_ENV === 'production') {
        await autoUpdater.checkForUpdates()

In package.json I have "version": "1.0.0", and inside build:{} I have:

"win": {
  "icon": "build/icons/icon.ico",
  "publish": [{
    "provider": "generic",
    "url": "https://quickmargo.pl/dist/download"

( I don't care about other platforms )

Now let's say I've made some changes in my app and I want to upload version 1.0.1 and I want my app to auto update if someone already downloaded installer and installed my app on his machine.

Tell me please if everything what I made so far is fine and what is next step. I consider following:

  • change version to 1.0.1 in package.json
  • run build command in terminal again
  • upload manually new installer to same place at my server
  • I did above three steps plus I also uploaded new latest.yml ( with version 1.0.1 ) and result is that when I now run previously installed (before uploading new version to server) version 1.0.0 on other PC then it doesn't detect that I added 1.0.1 to server and it doesn't update or show some popup or anything. What I'm doing wrong?

    Edit 2

    I'm trying to solve it on my own and now I uploaded 1.0.2 so now link to download app is:

    https://quickmargo.pl/dist/download/quickmargo Setup 1.0.2.exe

    Edit 3

    I was trying to solve it on my own I edited code in index.js. I edited also above. alert('Update required!'); on update-available event never occure. It should show me error message window that alert is undefined. But apparently update-available event is never emitted.

    Additional info:

  • My app was generated with vue-electron v1.0.6 boilerplate.
  • My electron-updater version is 4.1.2
  • npm run build actually invoke some code from boilerplate which is in .electron-vue/build.js you can see this file in above link (for example it set NODE_ENV to production. Script in package.json is: "build": "node .electron-vue/build.js && electron-builder",.
  • I don't want to host releases at github because my repository is private and I saw some information in electron.build docs that I shoudn't do that.
  • I also saw info in some issue that I could create new repo only for releases but I consider hosting everything at my own server as more clean approach.
  • There is an example here: github.com/iffy/electron-updater-example which covers "custom" updates – Lawrence Cherone Oct 27, 2019 at 19:03 Run your packed app via the cmd to see the logs, having these in the question can be helpful – oktapodia Oct 28, 2019 at 11:01 Do I need application to be signied with certificate in order to run auto-update correctly? – BT101 Oct 28, 2019 at 17:16 @dopeCode no, autoupdate should work without code signature, if you don't see any error after starting your built exe in the terminal, use a logger like electron-log to give the autoUpdater a logger to use ( const logger = require("electron-log"); autoUpdater.logger = logger; logger.transports.file.level = "debug";) - this should print out information if your server was found and whether an update was found. If you get an error you can add it to your question. – Rhayene Oct 29, 2019 at 17:44

    I was able to set up an auto update configuration using a generic publish option following the docs, having never done it before. So it's definitively doable, and it does not require signing via a certificate, but I initially had issues because I had set publisherName in the build config, but no certificate. If the current version had a publisher or certificate specified, and the new one does not, it will also not be installed.

    1. Enable logging

    You can enable logging of the electron-updater package by also installing electron-log and then assigning the logger to the autoUpdater:

    const log = require('electron-log');
    autoUpdater.logger = log;
    autoUpdater.logger.transports.file.level = 'info';
    

    The default output paths are:

  • Linux: ~/.config/<app name>/log.log
  • macOS: ~/Library/Logs/<app name>/log.log
  • Windows: %USERPROFILE%\AppData\Roaming\<app name>\log.log
  • If the following steps don't solve your issues, please post the log contents.

    2. Don't call autoUpdater.setFeedURL()

    The official docs state:

    Do not call setFeedURL. electron-builder automatically creates app-update.yml file for you on build in the resources (this file is internal, you don’t need to be aware of it).

    The URL is already defined in your publish provider object and that's enough for the updater to work with. Also, a URL string as argument of setFeedURL() is incorrect, it should be an options object. But again, specifying everything in your publish provider is sufficient.

    3. Also upload the .blockmap files to your server

    These should be created upon build in addition to your setup .exe files. Otherwise, you will see errors in your log that the files of the old and new version could not be found for comparison.

    4. Add a trailing slash to your update server URL

    Make sure that the url parameter of your provider object ends with a slash. While the yml file may still be found without it, there can be issues during the actual download otherwise.

    5. Try the simpler approach using autoUpdater.checkForUpdatesAndNotify()

    Instead of using the more flexible, but also more complicated way listening to the different update events and reacting to them within your app, try to get it to work with the following code first. Once that works, you can still go back to handling the different events for a better user experience.

    app.on('ready', async () => {
      autoUpdater.checkForUpdatesAndNotify();
    

    This will check for and download the update in the background and automatically install it as soon as you close your app. A default Windows notification will pop up to inform you about the available update and the procedure.

    I added logger and now I see that it actually find new release, it even shows how many kb need to be downloaded: Full: 151,317.35 KB, To download: 1,152.69 KB (1%) but after that nothing happen.. App is not updating. Are you sure that checkForUpdatesAndNotify is enough to make app quit if it found new release then download new release and install it? – BT101 Nov 18, 2019 at 19:48 Well I added this listeners back again and on update-available I log some text which I can see but update-downloaded is never emitted as I can not see log on this event. What might be the reason that it doesn't start/finish (tbh I don't even know which one) downloading? – BT101 Nov 18, 2019 at 21:00 checkForUpdatesAndNotify should show a notification once the download was successful and then the app should update once you close it. But if the update-downloaded event never fires, you won't get that far. However, it's hard for me to say what's causing the issue. – Constantin Groß Nov 19, 2019 at 6:43 Yes that's basically my behaviour update-available is emitted but update-downloaded is not. I don't know why yet. I'll try to reproduce it new, emty repository. – BT101 Nov 19, 2019 at 20:17 Yhm now it started to work. Although I didn't change single line of code. I just waited like a day, during that time restarted PC also. It's working but it's downloading full app and it log error: Cannot download differentially, fallback to full download: Error: Received data length 1527 is not equal to expected 634. Also it try to update after app exit and ask for admin permission. And if I don't allow then I can run app again with previous version which is behaviour that I don't want. I want to force users to install update. I'm using autoUpdater.quitAndInstall() but it's not quiting. – BT101 Nov 20, 2019 at 12:55

    I would like to introduce https://github.com/electron-delta/electron-delta-updater here.

    It uses the binary diffing approach to generate very small delta files to update your app instead of the older blockmap approach.

    npm install @electron-delta/updater
    
    const DeltaUpdater = require("@electron-delta/updater");
    const { app, BrowserWindow } = require("electron");
    app.whenReady().then(async () => {
      const deltaUpdater = new DeltaUpdater({
        logger: require('electron-log'),
        // optionally set the autoUpdater from electron-updater
        autoUpdater: require("electron-updater").autoUpdater,
        // Where delta.json is hosted, for github provider it's not required to set the hostURL
        hostURL: "https://example.com/updates/windows/",
      try {
        await deltaUpdater.boot();
      } catch (error) {
        logger.error(error);
      // create main app window after the deltaUpdater.boot()
      createMainWindow();
            

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.