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

Winget PowerShell commands failing

Open RygelXVI opened this issue 2 years ago • 11 comments

Brief description of your issue

attempting to use any winget powershell commands will fail with "Get-WinGetPackage: Failed to create instance: -2147483633" using Get-WinGetPackage -Verbose -Debug does not produce further information. using try { get-wingetpackage } catch { $_.exception } captures the following stacktrace:

ErrorCode      : -2147483633
TargetSite     : T Create[T](System.Type, System.Guid ByRef)
Message        : Failed to create instance: -2147483633
Data           : {}
InnerException :
HelpLink       :
Source         : Microsoft.WinGet.Client.Engine
HResult        : -2147483633
StackTrace     :    at Microsoft.WinGet.Client.Engine.Helpers.ComObjectFactory.Create[T](Type type, Guid& iid)
                    at
                 Microsoft.WinGet.Client.Engine.Helpers.ComObjectFactory.CreateCreateCompositePackageCatalogOptions()
                    at Microsoft.WinGet.Client.Engine.Commands.Common.FinderCommand.GetPackageCatalogReference(Composit
                 eSearchBehavior behavior)
                    at Microsoft.WinGet.Client.Engine.Commands.Common.FinderCommand.GetPackageCatalog(CompositeSearchBe
                 havior behavior)
                    at
                 Microsoft.WinGet.Client.Engine.Commands.Common.FinderCommand.FindPackages(CompositeSearchBehavior
                 behavior, UInt32 limit)
                    at Microsoft.WinGet.Client.Engine.Commands.Common.FinderExtendedCommand.FindPackages(CompositeSearc
                 hBehavior behavior)
                    at Microsoft.WinGet.Client.Engine.Commands.FinderPackageCommand.Get()
                    at Microsoft.WinGet.Client.Commands.GetPackageCmdlet.ProcessRecord()
                    at System.Management.Automation.CommandProcessor.ProcessRecord()

Steps to reproduce

use a winget powershell command, e.g. get-wingetpackage | where { $_.Isupdateavailable }

Expected behavior

a list of packages with updates available to be displayed in the shell (in fact the same list of packages that would be displayed using winget upgrade

Actual behavior

error message "Get-WinGetPackage: Failed to create instance: -2147483633" is returned

Environment

Windows Package Manager (Preview) v1.7.2782-preview
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.22621.2428
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.22.2782.0

Winget Directories
-----------------------------------------------------------------------------------------------------------------------
Logs                               %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\Diag…
User Settings                      %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\sett…
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                        Disabled
BypassCertificatePinningForMicrosoftStore Disabled
InstallerHashOverride                     Disabled
LocalArchiveMalwareScanOverride           Disabled

RygelXVI avatar Oct 23 '23 10:10 RygelXVI

What version of PowerShell are you using?

Trenly avatar Oct 23 '23 12:10 Trenly

I'm using PowerShell 7.3.8, behaviour is also the same on 7.3.7

RygelXVI avatar Oct 24 '23 12:10 RygelXVI

Ran into a similar issue. Got the same "Failed to create instance: -2147483633" error with v0.2.2 but only when running Find-WingetPackage command in a script that was launched from an Scheduled Task with the Run whether user is logged on or not box checked on a Windows 10 workstation! Very unique! It worked properly in interactive sessions and in Windows 11. Downgrading the module to v0.2.1 didn't change anything, but then downgrading to v0.2.0 seems to have fixed the issue at first but it happened later on when I tried it again!

AmirTerani avatar Oct 24 '23 21:10 AmirTerani

This looks like a problem with the MSIX-installed (user-scoped) version of PowerShell. Running it through the MSI-installed (machine-scoped) powershell works for me

https://github.com/microsoft/winget-cli/assets/88161975/12b77b8a-f3aa-4ff9-b342-84cf495e6bc1

cc @denelon

Note: If you want the MSI installer of PowerShell, you can get it using winget download Microsoft.PowerShell --installer-type wix

mdanish-kh avatar Oct 25 '23 05:10 mdanish-kh

on this (work) computer, PowerShell was installed from the Microsoft Store.
I don't see this problem on my personal computer, where PowerShell was installed with WinGet.

Can anyone clarify why there are issues between how PowerShell is installed? This seems very strange to me. Also why does using the -Verbose and -Debug switches not return any further information?

RygelXVI avatar Oct 25 '23 07:10 RygelXVI

I just uninstalled PS7 MSIX and manually downloaded and installed the MSI package. Still getting the same error when run the script from an Scheduled Task. Works fine in the console! Very odd!

AmirTerani avatar Oct 25 '23 14:10 AmirTerani

Seem related to #3826

eabase avatar Oct 28 '23 17:10 eabase

In PowerToys, we're using https://www.powershellgallery.com/packages/Microsoft.WinGet.Client/1.6.3133.0 as a dependency on a new utility: Command Not Found. Unfortunately the plugin doesn't work on PowerShell when installed from the Microsoft Store or from .msix.

Ref: https://github.com/microsoft/PowerToys/issues/30818

jaimecbernardo avatar Jan 09 '24 15:01 jaimecbernardo

In PowerToys, we're using https://www.powershellgallery.com/packages/Microsoft.WinGet.Client/1.6.3133.0 as a dependency on a new utility: Command Not Found. Unfortunately the plugin doesn't work on PowerShell when installed from the Microsoft Store or from .msix.

Ref: microsoft/PowerToys#30818

Is there a third installation method that IS supported, then? I'm on Win11 and I'm trying to get it to work but I don't know how to update the bundled Powershell to version 7.**, just install the newer version as an MSIX

Logue-0 avatar Jan 25 '24 07:01 Logue-0

Damn, MSIX is still a second-class citizen, even today? :(

Neme12 avatar Mar 02 '24 21:03 Neme12

It seems like the MSIX version now works? Successful Get-WinGetPackage invocation with PSHOME indicating an MSIX installation of PowerShell

dongle-the-gadget avatar Jun 09 '24 14:06 dongle-the-gadget

Can anyone confirm this has been fixed in the latest version of Microsoft.WinGet.Client? I believe this issue has been resolved.

denelon avatar Jul 26 '24 22:07 denelon

Hi @denelon , I can confirm the issue has been fixed for the use case in PowerToys when installing from the Microsoft Store. Thank you!

jaimecbernardo avatar Jul 27 '24 13:07 jaimecbernardo

Works for me too. Thanks!

oldium avatar Jul 30 '24 11:07 oldium

Should we closed this? Seems like it's fixed.

dongle-the-gadget avatar Aug 06 '24 15:08 dongle-the-gadget