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

fix: (mac) Fix intel mac upgrade flow when both x64 and arm64 published #6212

Merged

Conversation

johnnyopao
Copy link
Contributor

@johnnyopao johnnyopao commented Aug 30, 2021

On Intel macs, the error No files provided is thrown on the latest version of electron-updater (4.5.1) when the latest files include both arm64 and x64 builds.

The current filtering done when there are arm64 files available will return an empty array since there are arm64 files but we are not on a arm64 machine

if (files.some(isArm64)) {
files = files.filter(file => (process.arch === "arm64" || isRosetta) === isArm64(file))
}

This change adjusts MacUpdater to filter the files to this criteria:

  • On an Intel Mac: Filter files to only include non-arm64 builds
  • On an arm64 Mac: Filter files to only include arm64 builds
  • If no arm64 builds are available: This will fallback to the condition to filter files to only include non-arm64 builds

Steps to reproduce the bug:

  1. Install "electron-updater": "^4.5.1"
  2. Publish two versions of your app with both x64 and arm64 builds
electron-builder -p always --mac --x64 --arm64 
  1. On an intel mac try to upgrade from the previous version to another

Expected Behavior
The files list is filtered down and the x64/intel build is selected for download

Actual behavior
No files are returned after filtering. The Error: No files provided error is thrown

@changeset-bot
Copy link

changeset-bot bot commented Aug 30, 2021

🦋 Changeset detected

Latest commit: 794787f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
electron-updater Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mmaietta mmaietta merged commit 0c21cd6 into electron-userland:master Sep 1, 2021
@github-actions github-actions bot mentioned this pull request Sep 1, 2021
// allow arm64 macs to install universal or rosetta2(x64) - https://github.com/electron-userland/electron-builder/pull/5524
const isArm64 = (file: ResolvedUpdateFileInfo) => file.url.pathname.includes("arm64") || file.info.url?.includes("arm64")
if (files.some(isArm64)) {
files = files.filter(file => (process.arch === "arm64" || isRosetta) === isArm64(file))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind explaining the change you made here, @johnnyopao? From my understanding, files = files.filter(file => (process.arch === "arm64" || isRosetta) === isArm64(file)) already handles both Intel & ARM64 cases. It would be equivalent to files = files.filter(file => true === isArm64(file)) on ARM64 Macs and files = files.filter(file => false === isArm64(file)) on Intel Macs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, isRosetta could be undefined, causing the problem.

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

Successfully merging this pull request may close these issues.

None yet

3 participants