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

Auto update doesn't work: app-update.yml is missing #4233

Closed
thisismydesign opened this issue Sep 12, 2019 · 38 comments
Closed

Auto update doesn't work: app-update.yml is missing #4233

thisismydesign opened this issue Sep 12, 2019 · 38 comments

Comments

@thisismydesign
Copy link

  • Version: ^20.44.4
  • electron-updater Version: ^4.0.14
  • Target: --win --x64 NSIS

We noticed that auto-update doesn't work on our newly released app. In our entry point we have:

import { autoUpdater } from "electron-updater";

// ...

autoUpdater.setFeedURL({
  provider: "github",
  owner: "org",
  repo: "repo",
});
  • No publish config in package.json
  • No GH_TOKEN
  • built on GitLab's CI
  • the initial release didn't have a latest.yml file

We don't have logs about what the actual error might be. We did many tests before and after with the same and similar setups and it seems to work for the most part (even without publish config). Nevertheless, we managed to probably reproduce the issue by setting up dummy projects in the same environment and we got:

An update is available.
Error in auto-updater. Error: ENOENT: no such file or directory, open 'C:\Users\xyz\AppData\Local\Programs\electron-updater-example\resources\app-update.yml'

The main difference being the environment, and in this particular environment if the publish config is initially unset, app-update.yml was not found in the installed app. Most interestingly, after removing the publish config app-update.yml is still there.

To reproduce:

Found a few mentions about app-update.yml not being found, most notably: #2736 (comment)

But it's never clear anywhere whether this is a known bug or what's causing it and why this behavior seemingly isn't idempotent.

I'd like to understand how to fix it and whether we have any recourse for resurrecting auto-updates for existing users (in case there could be other reasons for this behavior).

@danlester
Copy link

In case it helps anyone, I ran into this issue when my package.json's build:win contained "target": [ "zip", "msi" ].
When I changed this to "nsis" instead of "msi" I found that app-update.yml started to be generated correctly. (Perhaps just try all three zip, msi, nsis if it's msi you're after...)

@stale
Copy link

stale bot commented Nov 30, 2019

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the backlog label Nov 30, 2019
@thisismydesign
Copy link
Author

Still relevant

@stale stale bot removed the backlog label Nov 30, 2019
@migliorinie
Copy link
Contributor

I have the same problem.

- Version: ^22.2.0
- electron-updater Version: ^4.2.0
- target: win x64 portable

The autoupdater is created as const { autoUpdater } = require("electron-updater")
The application is packed with electron-builder -w --publish always
The relevant lines in package.json are

"build": {
    "appId": "com.app.id",
    "productName": "prodName",
    "copyright": "Copyright © 2019 ${author}",
    "win": {
      "target": "portable",
      "icon": "assets/icon4.png",
      "publish": {
        "provider": "generic",
        "url": "http://updateurl.com/"
    }
  }
}

And the error I get in the log is

[2019-12-03 11:49:33.109] [info] Checking for update
[2019-12-03 11:49:33.209] [error] Error: Error: ENOENT: no such file or directory, open 'C:\Users\xyz\AppData\Local\Temp\1UTA56tjgEk9mjIZSBjQlkSgllh\resources\app-update.yml'

The .yml file and latest.yml are properly generated if I build with "nsis" target.

@pablocar80
Copy link

I ran into this problem when the publish key is defined at the appImage level and not at the linux level. In that case, the app-update.yml file is not generated.

@stale
Copy link

stale bot commented Mar 14, 2020

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the backlog label Mar 14, 2020
@thisismydesign
Copy link
Author

thisismydesign commented Mar 14, 2020

Is this still relevant?

Very

@stale stale bot removed the backlog label Mar 14, 2020
@AzeemMichael
Copy link

Is there any progress on this? It's April 14, 2020, and, this issue is still not resolved. I tried to manually add my own app-update.yml file. But, doing so causes mac security to think the app was modified after being notarized.

@AzeemMichael
Copy link

Since there is no fix on this yet. I added "afterPack": "./afterPackHook.js", in the build part of package.json. afterPackHook.js file contains the code below. It generates the missing app-update.yml, however, after the new version is downloaded I get an error.

Error after new version is downloaded

New version 1.3.2 has been downloaded to /Users/amichael/Library/Application Support/Caches/demoapp-updater/pending/Demo App-1.3.2-mac.zip
/ requested
/1587329652828-8531.zip requested
/1587329652828-8531.zip requested by Squirrel.Mac, pipe /Users/amichael/Library/Application Support/Caches/demoapp-updater/pending/Demo App-1.3.2-mac.zip
Error: Error: ENOENT: no such file or directory, rename '/Users/amichael/Library/Application Support/Caches/demoapp-updater/pending/temp-Demo App-1.3.2-mac.zip' -> '/Users/amichael/Library/Application Support/Caches/demoapp-updater/pending/Demo App-1.3.2-mac.zip'

afterPackHook.js

'use strict'
const fs = require('fs')
const path = require('path')
const yaml = require('js-yaml')
exports.default = async context => {
    let data = {
        provider: 'spaces',
        name: 'demoapp',
        region: 'nyc3',
        path: '/test/'
    }
    switch (process.platform) {
        case "win32":
            data.updaterCacheDirName = 'demo-app-updater'
            data.publisherName = ['Company Name LLC']
            fs.writeFileSync(
                path.join(__dirname, 'dist','win-unpacked','resources','app-update.yml')
                , yaml.safeDump(data)
                , 'utf8'
            )
            break
        default: // unix
            data.updaterCacheDirName = 'demoapp-updater'
            fs.writeFileSync(
                path.join(__dirname, 'dist','mac','Demo App.app','Contents','Resources','app-update.yml')
                , yaml.safeDump(data)
                , 'utf8'
            )
            break
    }
    fs.writeFileSync(
        path.join(__dirname, 'dev-app-update.yml')
        , yaml.safeDump(data)
        , 'utf8'
    )
}

@xxczaki
Copy link

xxczaki commented May 19, 2020

This issue still exists on electron-builder@^22.6.0, tested on Windows 10 Pro (latest) and Linux Mint 19.3. I tried everything, including using the not-recommended setFeedURL, but nothing seems to work.

Every time user launches my app they see:

Unhandled Promise Rejection Error: ENOENT: no such file or directory, open '/opt/APP_NAME/resources/app-update.yml'

I checked the folder and the only file there is app.asar.

cc @develar

@stale
Copy link

stale bot commented Jul 25, 2020

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the backlog label Jul 25, 2020
@thisismydesign
Copy link
Author

Don't close this issue. This is an automatic message by Fresh - a bot against stale bots.

@stale stale bot removed the backlog label Jul 25, 2020
@sukolenvo
Copy link

Hi, in case somebody has same issue (app-update.yml missing on Windows). Its generated only if one of the following targets is enabled: nsis or nsis-web. If you building only portable or zip + msi or any other combination of targets that doesn't include nsis - app-update.yml won't be generated as target is not "suitable" (source).

Also note, that this after pack handler that generates app-update.yml checks only build and platform publish config - it won't generate config, if it set on target level on Windows/Mac.

And finally one more tip if you are building msi with auto-update: adding nsis target will trick builder to generate app-update.yml. But another important file that is required for updates elevate.exe is copied only as part of the following targets: nsis, nsis-web, portable, but not msi. Without this file when user will click install and restart application, it may crash with following error:
image
Its not reproducing every time, you might successfully build few releases and then following erorr might happen because msi and other targets are build in parallel. So, on one build msi might be slower and nsis or portable target will copy elevate.exe into pack folder, next time nsis might be slower and msi will end up without elevate.exe. Links to source: all targets build in parallel, copyElevateHelper registration

@Vadi
Copy link

Vadi commented Aug 27, 2020

Any updates on this issue? This is still happening.

@aayusharora
Copy link

Any updates?
We are also facing the same

@egor-xyz
Copy link

egor-xyz commented Sep 30, 2020

app-update.yml missing on Mac too if target: ["dir"]

Founded in docs

zip target for macOS is required for Squirrel.Mac, otherwise latest-mac.yml cannot be created, which causes autoUpdater error. Default target for macOS is dmg+zip, so there is no need to explicitly specify target.

@dodois
Copy link

dodois commented Oct 23, 2020

The problem remains.

[2020-10-23 23:36:35.664] [error] Error: Error: ENOENT: no such file or directory, open 'C:\Users\xxx\AppData\Local\Temp\1jHfEUq4XtWD9LmPfvcOFcWKQL2\resources\app-update.yml'

@bblanke
Copy link

bblanke commented Oct 26, 2020

Thank you @AndrewReisdorph this worked like a charm

@jxryft
Copy link

jxryft commented Oct 27, 2020

I was having the same issue, even though my build was working fine. I found that I have to have nsis in lowercase, it was previously uppercase. After doing so the app-update.yml and resources folder were properly built. I don't know if this helps anyone but I thought I'd share.

"build": {
    "appId": "APP NAME HERE",
    "win": {
      "target": "nsis"
    },

@Amethystafyy282
Copy link

I've encountered this issue while building on Debian 18.04. Christmas is coming, I can see where my holidays will go with this :(

@sontd-0882
Copy link

Same here on Ubuntu 18.04.

@neogenz
Copy link

neogenz commented Jan 28, 2021

Always nothing new ?

@stephanebouget
Copy link

Same issue for me on Linux only:
Error: ENOENT: no such file or directory, open '/opt/app_name/resources/app-update.yml'

But it works well on Windows and Mac !

@stephanebouget
Copy link

Seems to be resolved with the latest version of Electron Builder : 22.11.1
https://github.com/electron-userland/electron-builder/releases/tag/v22.11.1

@ianoble
Copy link

ianoble commented May 6, 2021

Still having the issue for Windows:

"electron-builder": "^22.11.1",

That file (dev-app-update.yml) doesn't exist anywhere on my machine. Why is it trying to find it??

My dist_electron directory:

image

@FranzJoseph17
Copy link

I fixed this and here's how:

My os and arch are Windows 10 Home - x64
My code that failed to generate app-update.yml:

"build": {
  ...
  "directories": {
    ...
  },
  "win": {
    "target": "nsis",
    "verifyUpdateCodeSignature": false,
  },
  "nsis": {
    "deleteAppDataOnUninstall": true
  }
},
"publish": {
  "provider": "generic",
  "url": "http://xx.xx.xx.xx:port/update/win64",
  "useMultipleRangeRequest": false
},
...

My working code:

"build": {
  ...
  "directories": {
    ...
  },
  "win": {
    "target": "nsis",
    "verifyUpdateCodeSignature": false,
    "publish": {
      "provider": "generic",
      "url": "http://xx.xx.xx.xx:port/update/win64",
      "useMultipleRangeRequest": false
    }
  },
  "nsis": {
    "deleteAppDataOnUninstall": true
  }
},
...

What did the trick was moving the publish config inside the win config.

The build process didn't output any errors or warnings about this "misplacement" but there are definitely consequences, maybe it would be wise to output a warning when something like this happens.

@stale
Copy link

stale bot commented Jul 31, 2021

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the backlog label Jul 31, 2021
@KyomiTeam
Copy link

Hi !
I had this porblem before. But now it's work and I don't how I did. Just look my code if you need :

  • My package.json :
    { "name": "kyo-panel-app", "productName": "kyo-panel-app", "version": "0.0.1", "description": "A minimal Electron application", "main": "main.js", "scripts": { "start": "electron .", "pack": "electron-builder --dir", "dist": "electron-builder", "publish": "electron-builder -w --publish always" }, "build": { "appId": "com.github.KyomiTeam.kyo-app-alpha", "publish": [ { "provider": "github", "owner": "KyomiTeam", "repo": "kyo-app-alpha" } ], "win": { "target": [ "nsis", "zip" ], "icon": "", "publish": { "provider": "github", "owner": "KyomiTeam", "repo": "kyo-app-alpha" } }, "nsis": { "installerIcon": "", "uninstallerIcon": "", "uninstallDisplayName": "Uninstaller - Kyo Panel App", "license": "./LICENSE.md", "oneClick": false, "allowToChangeInstallationDirectory": true, "perMachine": true } }, "author": "Kyomi", "devDependencies": { "electron": "^13.1.7", "electron-builder": "^22.11.7" }, "dependencies": { "electron-log": "^4.4.1", "electron-updater": "^4.3.9", "firebase": "^8.8.1", "firebase-admin": "^9.11.0", "fortnite-api-io": "^1.9.0", "update-electron-app": "^2.0.1" } }

@stale stale bot removed the backlog label Aug 6, 2021
@elinake
Copy link

elinake commented Sep 29, 2021

The default setting that Electron generates, is to have electron-builder.config.json like

"publish": {...  },
"nsis": {..  },
"win": {... },

For some commenters, moving publish inside win was the solution. However, that didn't work for me with electron-builder version 22.10.5. I can't upgrade to version 22.11.7, because that version has a bug with fs/promises, which would possibly be solved by upgrading to Node 14 (from current 12), which I can't do right now. https://stackoverflow.com/questions/68085375/cannot-find-module-fs-promises-electron-js

@mhosken
Copy link

mhosken commented Nov 1, 2021

How is an end user affected by an application with this bug supposed to work around this? Is there some mystical incantation that can be put into the offending file to allow the application to actually run. I don't want automatic updates. I just want the app to run. Waaail :)

@panther7
Copy link
Contributor

panther7 commented Jan 7, 2022

It would be nice if the file app-update.yml was generated independently of the targets.

@GiovanH
Copy link

GiovanH commented Jan 31, 2022

This major bug is still present, three years later.

@reaz1995
Copy link

reaz1995 commented Feb 1, 2022

my package.json

...
"scripts":{
"package:deploy": "cross-env GH_TOKEN=<access_token> electron-builder  -w -p always",
}
...
"build": {
   ...
    "win": {
      "target": "nsis"
    },
    "publish": {
      "provider": "github",
      "owner": "<username>",
      "repo": "<reponame>",
      "vPrefixedTagName": true
    },
    "nsis": {
      "oneClick": false,
      "allowToChangeInstallationDirectory": true
    }
  }

main.ts

import { app, BrowserWindow, ipcMain, dialog, globalShortcut } from "electron";
import { autoUpdater } from "electron-updater";
import log from "electron-log";
log.transports.file.level = "info";
autoUpdater.logger = log;
autoUpdater.checkForUpdates();

autoUpdater.on("update-available", () => {
  log.info("update-available");
  const dialogOpts = {
    type: "info",
    buttons: ["Restart", "Later"],
    title: "Application Update",
    message: "update",
    detail:
      "A new version has been downloaded. Restart the application to apply the updates.",
  };

  dialog.showMessageBox(dialogOpts).then((returnValue) => {
    if (returnValue.response === 0) autoUpdater.quitAndInstall();
  });
});

autoUpdater.on("error", (e) => {
  dialog.showMessageBox(mainWindow, { message: (e as Error).message });
  console.error("There was a problem updating the application");
  console.error(e);
});

i created public repo with only readme.md, then deployed release -> published release -> downloaded installer -> installed -> files structure in ressources dir:
image
app-update.yml :
image

created new release, to get something to update my app to :), and everything work correct:
image

@weeebdev
Copy link

Same issue for me on Linux only: Error: ENOENT: no such file or directory, open '/opt/app_name/resources/app-update.yml'

But it works well on Windows and Mac !

how did you resolve it on linux?

@adamkpickering
Copy link

adamkpickering commented Mar 1, 2022

I'm having a related problem. Our macOS and Windows builds work fine, but in the case of Linux it seems that app-image.yml is not being generated.

Here are some details about my use case. We don't build the AppImage directly with electron-builder. Instead, we build to zip and then take that zip file and feed it into our build system, which builds it into a deb, an rpm and an AppImage. Updates are taken care of for the deb and rpm, but we'd like to use the update mechanism for the AppImage. However, as I said above, app-update.yml is not being generated for the zip file build. This means that the final AppImage does not contain app-update.yml, so it does not know how to find out if there is a newer version.

After doing some pretty significant digging into the electron-builder code, the only way I can see to work around this is for us to include an independent app-update.yml file in the project's resources directory (i.e. one that is hard-coded and not generated from electron-builder.yml) and then parse it and pass it in the options to an AppImageUpdater. But this is not a good idea for a number of reasons.

As panther7 said above, it would be nice if app-update.yml could be generated independently of the targets.

@Spectrum-Elliott
Copy link

Spectrum-Elliott commented Mar 8, 2022

Just wanted to chime in and say that if you want the app to just launch without errors and don't care about having the update functionality functioning, I found a way that works for me.

In index.js, comment out this line
autoUpdater.checkForUpdatesAndNotify();

Edit: (And/Or in index.ts, you will find that same line and comment it out).

It seems to ignore checking for app-update.yaml.

This is with electron versioned at ^14.0.0 and electron-builder on the latest version (22.14.13).

Sadly, none of the methods I have tried in the past few hours have provided any luck to actually generating a working app-update.yaml. It's unfortunate because the feature would be really nice to have, but at least the user isn't presented with an error window opening the app.

@keyurchitroda
Copy link

I'm using electron builder to auto-update my app for mac, windows & ubuntu OS. mac & windows are working fine. But, the Ubuntu deb package app is throwing errors while it's updating as I attach error logs below. I've tried some solutions available on web but didn't get the solution.

Error: Error: ENOENT: no such file or directory, open '/opt/Centroall Tracker/resources/app-update.yml'

electron=11.5.0,
electron-builder=22.11.7,
electron-updater=4.6.5

@mmaietta
Copy link
Collaborator

@keyurchitroda only AppImage supports auto-updates on linux.

This ticket has deviated far from it's original electron-builder version and the reported core issue: NSIS. Closing this. Please open new issues to target your specific OS/usecase

@electron-userland electron-userland locked and limited conversation to collaborators Mar 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests