microsoft / microsoft/winget-cli
Repair-WinGetPackageManager outputs noise in PowerShell transcripts
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 26.4k
- Forks
- 1.8k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 15
Description
Brief description of your issue
The log file for the WinGet bootstrapping outputs the following:
The term 'winget' is not recognized as a name of a cmdlet, function, script file, or executable program.
This happens even though we don`t call winget.exe directly in the bootstrapping-script, we just run Repair-WinGetPackageManager to install WinGet.
Simple repro on a fresh 2022 VM:
I suspect this is due to some internal workings of Repair-WinGetPackageManager checking for the existence of winget before installing it if not present.
I`m not too familiar with C# - but seems like the relevant parts are here
https://github.com/microsoft/winget-cli/blob/master/src/PowerShell/Microsoft.WinGet.Client.Engine/Commands/WinGetPackageManagerCommand.cs#L91
and here
https://github.com/microsoft/winget-cli/blob/master/src/PowerShell/Microsoft.WinGet.Client.Engine/Common/WinGetIntegrity.cs#L98
Suggestions for possible solutions:
- Add a -Force switch to Repair-WinGetPackageManager to make it skip checking existence of winget.exe
- Add a separate Install-WinGetPackageManager which can be used for bootstrapping scenarios
- Suppress the output of the presence of winget.exe
Steps to reproduce
On a machine which does not have WinGet installed, open PowerShell 7 and run the following:
Start-Transcript
Install-Module -Name Microsoft.WinGet.Client
$null = Repair-WinGetPackageManager -AllUsers
Stop-Transcript
Expected behavior
Repair-WinGetPackageManager should not output the following to the PowerShell transcript log file:
`The term 'winget' is not recognized as a name of a cmdlet, function, script file, or executable program.
Actual behavior
Repair-WinGetPackageManager outputs the following to the PowerShell transcript log file:
`The term 'winget' is not recognized as a name of a cmdlet, function, script file, or executable program.
Environment
Windows Package Manager v1.6.3421
Copyright (c) Microsoft Corporation. All rights reserved.
Windows: Windows.Server v10.0.20348.2159
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.21.3421.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the referenced lines in src/PowerShell/Microsoft.WinGet.Client.Engine/Commands/WinGetPackageManagerCommand.cs and Common/WinGetIntegrity.cs, then reproduce on a machine without WinGet using the PowerShell transcript commands in the issue. Trace the existence check performed by Repair-WinGetPackageManager. Done means the command no longer adds the winget-not-found message to the transcript during bootstrapping.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100