winget-cli: Broken winget after installing Windows 11 and all its updates

Brief description of your issue

I have installed Windows 11 on a laptop and completed all the system updates. When I tried to run some winget commands like winget search or winget install I got an empty output, though the text color of the prompt would turn blue.

(1) I tried to update winget from the Microsoft Store but there was no Update button under App Installer.

(2) When I tried to uninstall winget and install it back with the command:

Get-AppxPackage | ? {$_.Name -match 'AppInstaller'} | Remove-AppxPackage; Add-AppxPackagehttps://aka.ms/getwinget

I got the following error:

Remove-AppxPackage : Deployment failed with HRESULT: 0x80073CFA, Removal failed. Please contact your software vendor. (Exception fro
m HRESULT: 0x80073CFA)
error 0x80070032: AppX Deployment Remove operation on package Microsoft.DesktopAppInstaller_1.21.2771.0_x64__8wekyb3d8bbwe from: C:\
Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.21.2771.0_x64__8wekyb3d8bbwe failed. This app is part of Windows and canno
t be uninstalled on a per-user basis. An administrator can attempt to remove the app from the computer using Turn Windows Features o
n or off. However, it may not be possible to uninstall the app.
NOTE: For additional information, look for [ActivityId] 88ce017c-0b27-000b-0340-cf88270bda01 in the Event Log or use the command lin
e Get-AppPackageLog -ActivityID 88ce017c-0b27-000b-0340-cf88270bda01
At line:1 char:55
+ ... kage | ? {$_.Name -match 'AppInstaller'} | Remove-AppxPackage; Add-Ap ...
+                                                ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (Microsoft.Deskt...__8wekyb3d8bbwe:String) [Remove-AppxPackage], IOException
    + FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.RemoveAppxPackageCommand

Add-AppxPackagehttps://aka.ms/getwinget : The term 'Add-AppxPackagehttps://aka.ms/getwinget' is not recognized as the name of a cmdl
et, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is c
orrect and try again.
At line:1 char:75
+ ... aller'} | Remove-AppxPackage; Add-AppxPackagehttps://aka.ms/getwinget
+                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                              + CategoryInfo          : ObjectNotFound: (Add-AppxPackagehttps://aka.ms/getwinget:String) [], CommandNotFoundException              + FullyQualifiedErrorId : CommandNotFoundException  

(3) When I ran:

winget source update

I got:

Updating all sources...
Updating source: msstore...
Done
Updating source: winget...
  ██████████████████████████████  100%
Done

and then winget started working.

Steps to reproduce

Install Windows 11 on a computer and install all the updates.

Expected behavior

winget is working.

Actual behavior

winget is not working.

Environment

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

Windows: Windows.Desktop v10.0.22621.2506
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.21.2771.0

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Reactions: 1
  • Comments: 21 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Likewise here just a minute ago. None of the potential fixes work on a brand new and freshly updated Win 11 install. Same “prompt turns blue” behavior and same error with the Powershell update process. Winget mostly seems to be hung up trying to interact with the winget source. The source update command worked fine for the store, but hung on the winget source.

Running this worked for me:

Invoke-WebRequest -Uri https://aka.ms/getwinget -OutFile winget.msixbundle
Add-AppPackage -ForceApplicationShutdown .\winget.msixbundle
del .\winget.msixbundle

The thing I changed, is adding the -ForceApplicationShutdown argument. For me, it fixed the issue @dschu012 mentioned and winget works fine on my system now.

After some more testing, on a newly installed Windows 11 23H2, the following Powershell commands suffice to get winget up and running:

Invoke-WebRequest -Uri https://aka.ms/getwinget -OutFile winget.msixbundle
Add-AppxPackage winget.msixbundle
del winget.msixbundle

Likewise here just a minute ago. None of the potential fixes work on a brand new and freshly updated Win 11 install. Same “prompt turns blue” behavior and same error with the Powershell update process. Winget mostly seems to be hung up trying to interact with the winget source. The source update command worked fine for the store, but hung on the winget source.

Running this worked for me:

Invoke-WebRequest -Uri https://aka.ms/getwinget -OutFile winget.msixbundle
Add-AppPackage -ForceApplicationShutdown .\winget.msixbundle
del .\winget.msixbundle

The thing I changed, is adding the -ForceApplicationShutdown argument. For me, it fixed the issue @dschu012 mentioned and winget works fine on my system now.

This also worked for me! thank you very much.

After some more testing, on a newly installed Windows 11 23H2, the following Powershell commands suffice to get winget up and running:

Invoke-WebRequest -Uri https://aka.ms/getwinget -OutFile winget.msixbundle
Add-AppxPackage winget.msixbundle
del winget.msixbundle

I get

Add-AppxPackage : Deployment failed with HRESULT: 0x80073D02, The package could not be installed because resources it   modifies are currently in use.
error 0x80073D02: Unable to install because the following apps need to be closed
Microsoft.DesktopAppInstaller_1.17.10691.0_x64__8wekyb3d8bbwe.
NOTE: For additional information, look for [ActivityId] 4685bc32-380f-0002-c01a-87460f38da01 in the Event Log or use
the command line Get-AppPackageLog -ActivityID 4685bc32-380f-0002-c01a-87460f38da01
At line:1 char:1
+ Add-AppxPackage winget.msixbundle
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (C:\Windows\system32\winget.msixbundle:String) [Add-AppxPackage], Exceptio
   n
    + FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.AddAppxPackageCommand

when doing that on a fresh Windows 11 23H2 install. winget source update nor any of the other solutions here seemed to work for me. All winget commands result in empty output and the prompt turning blue like the person who reported the issue.

Edit: Someone below mentioned adding -ForceApplicationShutdown to the Add-AppxPackage, that fixed it for me.

@lackovic

A fresh install of Windows 11 comes with an earlier version of WinGet. The Microsoft Store will “eventually” update this version to the latest, and once the latest version is present, it should function correctly. Sometimes this happens 15 minutes or so after the install, and other times it may take a bit longer depending on what else needs to be updated via the Microsoft Store on the system.

Is there any chance you have logs from those first couple of commands you tried when you didn’t get any output?

I suspect an upgrade may have been running during or immediately after those, and once the latest version was present, it started working.

I additionally needed to change to a directory other than C:\Windows\system32 (the default directory when starting Powershell in admin mode). Perhaps because the first command lacked write permissions for the downloaded file, even though the shell was run in admin mode. Unclear to me, but the steps below worked.

This worked:

# First, launch Powershell in administrator mode.

cd $HOME
Invoke-WebRequest -Uri https://aka.ms/getwinget -OutFile winget.msixbundle
Add-AppPackage -ForceApplicationShutdown .\winget.msixbundle
del .\winget.msixbundle

@mdanish-kh

Unfortunately, that PowerShell command doesn’t work: A progress bar shortly pops up, the command completes without error, but winget is still “broken”.

The sandbox script works, though. Thanks!

@HeinziAT

You can use the following PowerShell command

Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe

Reference: https://learn.microsoft.com/en-us/windows/package-manager/winget/#install-winget

You can also directly install winget with its dependencies through the sandbox script.

We are doing some work in future releases of Windows to reduce the time period for the registration activity

In the mean time, is there some workaround we can use? Maybe some CLI command that updates winget?

Having to wait an indeterminate amount of time with no indication of progress is a bit frustrating when setting up a new PC…

Thanks for sharing the log output. We are doing some work in future releases of Windows to reduce the time period for the registration activity, but for now sadly, this is the expected behavior.

Why? Everything is working after the 3rd solution I mentioned.

Sorry for not fully reading the Issue.