Romanitho / Winget-AutoUpdate

WAU daily updates apps as system and notify connected users. (Allowlist and Blocklist support)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: winget install check fails

soredake opened this issue · comments

The problem

################################################################
#     2/27/2024 -   INSTALLING WAU
################################################################
17:22:38 - Checking prerequisites...
17:22:39 - Prerequisites checked. OK

17:22:39 - Checking if WinGet is installed/up to date.
17:22:39 - -> WinGet is not installed

But winget is installed and working:

PS C:\Users\user> winget --version
v1.7.3481-preview

What version of WAU has the issue?

v1.19.2-7

What version of Windows are you using (ex. Windows 11 22H2)?

Windows 11 23H2

What version of winget are you using?

v1.7.3481-preview

Log information

Tested in pwsh 7.4.1

This line is failing

$WingetInstalledVersion = [regex]::match((& $WingetCmd -v), '((\d+\.)(\d+\.)(\d+))').Groups[1].Value

$WingetInstalledVersion = [regex]::match((& $WingetCmd -v), '((\d+\.)(\d+\.)(\d+))').Groups[1].Value
ResourceUnavailable: Program 'winget.exe' failed to run: StandardOutputEncoding is only supported when standard output is redirected.At line:1 char:44
+  $WingetInstalledVersion = [regex]::match((& $WingetCmd -v), '((\d+\. …
+                                            ~~~~~~~~~~~~~~~.
❯ $WingetInfo = (Get-Item "$env:ProgramFiles\WindowsApps\Microsoft.DesktopAppInstaller_*_8wekyb3d8bbwe\winget.exe").VersionInfo | Sort-Object -Property FileVersionRaw
❯ echo $WingetInfo

ProductVersion   FileVersion      FileName
--------------   -----------      --------
1.22.231214001-… 1.22.2312.14001  C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.22.3481.0_x64__8wekyb3d8bbwe\winget.exe
1.23.240222002-… 1.23.2402.22002  C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.23.532.0_x64__8wekyb3d8bbwe\winget.exe

❯ $WingetCmd = $WingetInfo[-1].FileName
❯ echo $WingetCmd
C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.23.532.0_x64__8wekyb3d8bbwe\winget.exe
❯ $WingetInstalledVersion = [regex]::match((& $WingetCmd -v), '((\d+\.)(\d+\.)(\d+))').Groups[1].Value
ResourceUnavailable: Program 'winget.exe' failed to run: StandardOutputEncoding is only supported when standard output is redirected.At line:1 char:43
+ $WingetInstalledVersion = [regex]::match((& $WingetCmd -v), '((\d+\.) …
+                                           ~~~~~~~~~~~~~~~.

Additional information

I have this installed https://github.com/jazzdelightsme/WingetPathUpdater

I think that the problem is caused by your powershell itself,
this section ((& $WingetCmd -v) launches the process which might get those two startInfo paramenters set to anything else than $null

  • StandardErrorEncoding
  • StandardOutputEncoding

.. and for some reason powershell 7 may not like it.

With legacy approach using [System.Diagnostics.ProcessStartInfo] and [System.Diagnostics.Process] I did not see such errors.

Parameter value
RedirectStandardInput False
RedirectStandardOutput True
RedirectStandardError True
StandardInputEncoding
StandardErrorEncoding
StandardOutputEncoding

I will propose an alternative to existing output capture method used currently in 'Update-WinGet.ps1'

keep in mind that you use a preview version of winget.

With the latest stable version, i no longer have this error, but this can change when WAU will update winget to the next preview version.

Maybe skip updating winget if their file in error contains -preview (or what it is called)?

thanks for reporting. We will have a look on that.

Since this problem is disappeared with latest versions, this can be closed for now.