winget-cli icon indicating copy to clipboard operation
winget-cli copied to clipboard

Winget Import: If "multiple packages" found - exits early, even if other packages left

Open JonLevin25 opened this issue 3 years ago • 4 comments

Brief description of your issue

Fresh install - tried to restore a winget export json from my old PC. It worked, until it encountered a couple VC++ Redistributables, citing Multiple packages found matching input criteria. Please refine the input. It also seems to have given up on a bunch of packages before the VC++ (as well as after). This is my main issue.

Steps to reproduce

Prerequisites- dont have the packages in the json installed.

  1. In powershell, run winget import on the manifest given (backup_winget_bug.json)
  2. outputs the following:
No applicable update found.
Multiple packages found matching input criteria. Please refine the input.
Name                                                   Id                                     Source
----------------------------------------------------------------------------------------------------
Microsoft Visual C++ 2015-2019 Redistributable (x64)   Microsoft.VC++2015-2019Redist-x64      winget
Microsoft Visual C++ 2015-2019 Redistributable (x86) … {38b2c744-ad08-4d5b-91a2-3fb6f739ff3e}
Package not found for import: Microsoft.VC++2015-2019Redist-x64
Multiple packages found matching input criteria. Please refine the input.
Name                                                   Id                                     Source
----------------------------------------------------------------------------------------------------
Microsoft Visual C++ 2015-2019 Redistributable (x86)   Microsoft.VC++2015-2019Redist-x86      winget
Microsoft Visual C++ 2015-2019 Redistributable (x86) … {38b2c744-ad08-4d5b-91a2-3fb6f739ff3e}
Package not found for import: Microsoft.VC++2015-2019Redist-x86```
[winget_import_bug.zip](https://github.com/microsoft/winget-cli/files/7006734/winget_import_bug.zip)
  1. Run the other manifest (backup_winget_works_reference.json), that doesn't have VC++ redists in it - works fine

Expected behavior

  1. Installer should not exit early because of ambiguous packages, instead outputting to stderr but trying to install the rest of the list
  2. generally - export and import Should be symmetric. Packages exported with winget export should always work when importing them with winget import. Meaning either the export should be more specific, or if there was enough metadata, the import should be able to handle this case.
  3. There should probably be an --exact / -e flag similar to winget install

Actual behavior

Installer exits early, and skips a bunch of packages

Environment

Windows Package Manager v1.0.11692 Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.19043.1165 Package: Microsoft.DesktopAppInstaller v1.12.11692.0

Attached jsons

winget_import_bug.zip

JonLevin25 avatar Aug 18 '21 11:08 JonLevin25

Does this still happen in Windows Package Manager 1.3?

denelon avatar Aug 08 '22 21:08 denelon

@JonLevin25 this issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.

ghost avatar Aug 15 '22 22:08 ghost

I tried this again now, but could not test due to #2569 It's a similar thing of winget import exiting early, but removing just the VCRedists did not fix it.

Perhaps this is an overarching issue of individual package installs not being isolated enough within the importer, or the importer not continuing when (any kind of) installation error occurs?

JonLevin25 avatar Oct 03 '22 10:10 JonLevin25

@JonLevin25 that seems like a decent hypothesis. We will have to trace down what is happening.

denelon avatar Oct 03 '22 16:10 denelon

@JonLevin25 We've just released WinGet 1.4 with several enhancements to the install flow. Can you verify if the problem reported here is still happening?

The "install" flow is now looking to see if the package is already installed. If it is, the flow can switch to the upgrade behavior which addresses packages requiring specific switches for upgrade. We've also added checks around "sets" of operations to attempt to continue when a single error is encountered.

denelon avatar Jan 23 '23 23:01 denelon

So I think this is fixed, though I couldn't check on a PC that doesn't have most packages, so most or all installs were no-ops.

Still, I think this bug used to repro in that situation.

This was my output

winget import .\backup_winget_bug.json Found an existing package already installed. Trying to upgrade the installed package... No package found matching input criteria. Package not found for import: Python.Python.3 Found an existing package already installed. Trying to upgrade the installed package... Found an existing package already installed. Trying to upgrade the installed package... No package found matching input criteria. Package not found for import: Microsoft.VC++2008Redist-x64 No package found matching input criteria. Package not found for import: Microsoft.VC++2015-2019Redist-x64 Found an existing package already installed. Trying to upgrade the installed package... No applicable upgrade found. Package is already installed: Microsoft.VisualStudioCode No package found matching input criteria. Package not found for import: Microsoft.VC++2008Redist-x86 Found an existing package already installed. Trying to upgrade the installed package... A newer version was found, but the install technology is different from the current version installed. Please uninstall the package and install the newer version. Package is already installed: Microsoft.PowerShell No package found matching input criteria. Package not found for import: UnityTechnologies.UnityHub No package found matching input criteria. Package not found for import: Microsoft.VC++2015-2019Redist-x86

JonLevin25 avatar Jan 24 '23 18:01 JonLevin25

Python.Python.3 was refactored into minor versions. The VC++ Redistributables were also refactored by architecture and the shape of the package identifiers also changed. PowerShell changed their installer technology.

I updated:

  • https://github.com/microsoft/winget-cli/issues/1924

It was originally just for architecture, but after looking at the output above, we clearly need to improve the output so users know what's going on.

I'm going to go ahead and close this Issue. Feel free to reopen or ping me if it's not resolved.

denelon avatar Jan 24 '23 18:01 denelon