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

Electron Updater using incorrect URL to download update from Github #6076

Closed
wardellbagby opened this issue Jul 21, 2021 · 2 comments · Fixed by #6117
Closed

Electron Updater using incorrect URL to download update from Github #6076

wardellbagby opened this issue Jul 21, 2021 · 2 comments · Fixed by #6117

Comments

@wardellbagby
Copy link
Contributor

wardellbagby commented Jul 21, 2021

  • Electron-Builder Version: 22.11.7
  • Node Version: 15.13.
  • Electron Version: 13.1.4
  • Electron Type (current, beta, nightly): current
  • Electron-Updater Version: 4.3.9
  • Target: Mac (DMG), Linux (AppImage, Deb), Windows (EXE)

I have an application (https://github.com/wardellbagby/lyricistant) that builds for web browsers, native desktop OSes (via Electron), Android devices, and iOS devices. I recently changed how I name my tags to include the platforms that were updated in that tag. E.g., if only Web is updated, the tag will be v.1.2.6-web. If Electron and Android are updated, it would be v.1.2.6-electron-android.

The problem I'm running into is it seems Electron Updater expects for tags to always be named in the form of v1.2.6, with no trailing information. I say this because I recently created v1.2.6-electron-web, and the app recognizes that it's an update for Electron, but tries to access the wrong URL for it.

Here are my relevant logs:

16:16:09.864 › Failed to download updates. Error: Cannot download "https://github.com/wardellbagby/lyricistant/releases/download/v1.2.6/lyricistant-mac_x64.zip", status 404:
    at ClientRequest.<anonymous> (/Applications/Lyricistant.app/Contents/Resources/app.asar/main.js:15421:34)
    at ClientRequest.emit (events.js:315:20)
    at SimpleURLLoaderWrapper.<anonymous> (electron/js2c/browser_init.js:105:6816)
    at SimpleURLLoaderWrapper.emit (events.js:315:20)

The URL should instead be https://github.com/wardellbagby/lyricistant/releases/download/v1.2.6-web-electron/lyricistant-mac_x64.dmg instead.

@mmaietta
Copy link
Collaborator

Looks like the version is being pulled from here:
https://github.com/electron-userland/electron-builder/blob/master/packages/app-builder-lib/src/publish/PublishManager.ts#L364
Version is being pulled from info.metadata.version which is straight from the package.json IIRC
https://github.com/electron-userland/electron-builder/blob/master/packages/app-builder-lib/src/appInfo.ts#L36
version can be explicity overridden I think using the electron-builder config property extraMetadata to override package.json values

@wardellbagby
Copy link
Contributor Author

wardellbagby commented Jul 26, 2021

So, it's 'cause the version in the latest-*.yml file isn't matching the tag name that GitHub has?

I've done some more delving here, and Electron Builder does correctly get the tag name from GitHub here. It then will successfully use that to create the URL to get the latest-*yml file here.

However, from then forward, it'll use the version from the latest-*.yml to create the URLs to download the files for Github even though it knew the correct GitHub tag name earlier. Looking at the code, that makes perfect sense, and it's probably only me that would even run into this, since most people are using tag names that perfectly match the version of the application.

However, it stills seems like getLatestVersion should return the tag name instead of the version in the yaml. But, I imagine it can't because it uses the yaml version for the semver check (although, I think my custom tag names should still pass semver, but I'm not sure.)

I could submit a PR to make this line look like:

return {
  ...result,
  version
}

which would just prefer the version that's actually on the tag name, but I feel like that might not be right? But still, I think the Electron Builder shouldn't throw away the tag name that it knows is valid in order to use the version string declared in the yaml. But maybe having the tag name perfectly match the version declared in the yaml is a requirement to use the update functionality?

wardellbagby added a commit to wardellbagby/electron-builder that referenced this issue Jul 31, 2021
Modify the GitHubProvider to provide the tag name of the latest
release as apart of its UpdateInfo (which is now encapsulated in the
GithubUpdateInfo interface) so that it uses that same tag name later
when it resolves the files to download.

fix electron-userland/issues/6076
wardellbagby added a commit to wardellbagby/electron-builder that referenced this issue Jul 31, 2021
Modify the GitHubProvider to provide the tag name of the latest
release as apart of its UpdateInfo (which is now encapsulated in the
GithubUpdateInfo interface) so that it uses that same tag name later
when it resolves the files to download.

fix electron-userland/issues/6076
wardellbagby added a commit to wardellbagby/electron-builder that referenced this issue Jul 31, 2021
Modify the GitHubProvider to provide the tag name of the latest
release as apart of its UpdateInfo (which is now encapsulated in the
GithubUpdateInfo interface) so that it uses that same tag name later
when it resolves the files to download.

fix electron-userland/issues/6076
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants