microsoft / microsoft/winget-cli

Exact match for Moniker not being selected for install

Open
#3,547 5 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue-Bug
Dominant language
C++
Stars
26.4k
Forks
1.8k
Avg merge
1d 11h
Merged PRs (30d)
15

Description

Brief description of your issue

When attempting an install, winget tries to select the best package matching user intent. This is done by assessing for exact matches on Moniker, ID, Name, and in some cases (such as uninstall) product code. If an exact match is found, the package is assumed to be the user intent and is selected for install.

The logic for this appears to be broken when both the msstore source and the winget source are enabled.

Steps to reproduce

Running winget search will provide a list of the packages matched by the search and what field they were matched on if the match was not part of the name or package identifier. winget search uses a substring match on the Name and Package identifier by default, but a case insensitive match on monikers, commands, tags, etc.

The specific reproduction steps rely on the Google Chrome package. Running winget search chrome -
WinGet-2023-08-23-10-23-37.093.log

PS C:\Windows\system32> winget search chrome --verbose
Name                                            Id                         Version        Match                 Source
-----------------------------------------------------------------------------------------------------------------------
DC Browser - Chrome and IE kernels              XP890QTFL1X0D0             Unknown                              msstore
DC Browser - Chrome and IE kernel               XP8BV7F2CT4LDK             Unknown                              msstore
Google Chrome                                   Google.Chrome              116.0.5845.111 Moniker: chrome       winget
Dichromate                                      Dichromate.Browser         110.0.5481.178 Command: chrome       winget
Google Chrome Dev                               Google.Chrome.Dev          117.0.5938.0   Command: chrome       winget
Google Chrome Beta                              Google.Chrome.Beta         117.0.5938.11  Command: chrome       winget
Chrome Remote Desktop Host                      Google.ChromeRemoteDesktop 112.0.5615.26  Tag: chrome           winget
Ginger Chrome                                   Saxo_Broko.GingerChrome    93.0.4529.0                          winget
<Results truncated for clarity>

From the search, it is clear that the first two entries are substring matches on the Name, the third entry is an exact match on moniker and substring matches on the Name and Package Identifier, and so on and so forth. Each entry in the list can be correlated to a match type.


Running winget install chrome -
WinGet-2023-08-23-10-24-04.956.log

PS C:\Windows\system32> winget install chrome --verbose
Multiple packages found matching input criteria. Please refine the input.
Name                               Id             Source
---------------------------------------------------------
DC Browser - Chrome and IE kernels XP890QTFL1X0D0 msstore
Google Chrome                      Google.Chrome  winget
Expected behavior

Because the package Google.Chrome from the winget source had an exact match on moniker, and there were no exact matches on Name or Package Identifier from any source, the Google.Chrome package should be selected for install.

Actual behavior

Multiple packages are being found as matching user intent - the package XP890QTFL1X0D0 from the msstore source, and Google.Chrome from the winget source.

Based on the results from winget show, the package XP890QTFL1X0D0 is only a substring match on the package name, whereas Google.Chrome is an exact match on the moniker. Because of the exact match on the moniker, this package should be selected for user intent above any substring matches on name or identifier.

Environment
PS C:\Windows\system32> winget --info
Windows Package Manager (Preview) v1.6.2291-preview
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.19041.3086
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.21.2291.0

Winget Directories
-------------------------------------------------------------------------------------------------------------------------------
Logs                               %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir
User Settings                      %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json
Portable Links Directory (User)    %LOCALAPPDATA%\Microsoft\WinGet\Links
Portable Links Directory (Machine) C:\Program Files\WinGet\Links
Portable Package Root (User)       %LOCALAPPDATA%\Microsoft\WinGet\Packages
Portable Package Root              C:\Program Files\WinGet\Packages
Portable Package Root (x86)        C:\Program Files (x86)\WinGet\Packages
Installer Downloads                %USERPROFILE%\Downloads

Links
---------------------------------------------------------------------------
Privacy Statement   https://aka.ms/winget-privacy
License Agreement   https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage            https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale

Admin Setting                             State
--------------------------------------------------
LocalManifestFiles                        Enabled
BypassCertificatePinningForMicrosoftStore Disabled
InstallerHashOverride                     Disabled
LocalArchiveMalwareScanOverride           Enabled

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the discrepancy with winget search chrome and winget install chrome while both the msstore and winget sources are enabled. Compare the match types reported by search with the selection logic used by install, focusing on exact moniker matches versus substring name matches across sources. Done means the exact Google.Chrome moniker match is selected without reporting multiple packages.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.