microsoft / winget-cli

WinGet is the Windows Package Manager. This project includes a CLI (Command Line Interface), PowerShell modules, and a COM (Component Object Model) API (Application Programming Interface).
https://learn.microsoft.com/windows/package-manager/
MIT License
23.38k stars 1.46k forks source link

Remove preference for "installed" installer type #4740

Closed JohnMcPMS closed 3 months ago

JohnMcPMS commented 3 months ago

Fixes #2565

Change

Move (and rename) the InstalledTypeComparator from being a comparator to just a filter. Given what we can (or rather, currently do) actually discern from system state, it doesn't make sense to give preference to the few types that we use to signify the compatibility sets. If we truly want to preserve installer type selection within a compatibility set, we need to store the user selection into the tracking database similar to UserIntentArchitecture.

Validation

Add a test for the case as called out by the issue; regression tests cover it as well and the only one that needed updating was relying on the intentionally changed behavior.

While this change is arguably "correct", it will cause different choices to be made if there are packages with multiple compatible installers that are equal in the other relevant dimensions. I'm working on determining the extent of impact to winget-pkgs via a custom validation pass.

If it turns out to be overly broad, the most likely solution will be to keep the existing behavior but drop from Strong to Weak for the case of equal installer types.

Microsoft Reviewers: Open in CodeFlow
JohnMcPMS commented 3 months ago

The only issue I uncovered when searching for package versions with installers in the same compatibility set that would be indistinct for upgrades was with multiple versions of ToEverything.AFFiNE (since they added an Nullsoft version of their installer). For example: https://github.com/microsoft/winget-pkgs/blob/master/manifests/t/ToEverything/AFFiNE/0.16.3/ToEverything.AFFiNE.installer.yaml

This is already an issue during upgrade, as for the same reason as the original issue we will prefer exe. With my change, the two x64, user scope installers will be equivalent in priority for upgrade (as they are for install already). We will still choose the exe as it comes first in the list rather than because it matches the detected type of exe.

This isn't really an issue, and it sets the likelihood of needing the UserIntentInstallerType to be implemented to very low.