jdhitsolutions / WingetTools

A set of PowerShell tools for working with the winget package manager.
MIT License
146 stars 14 forks source link

Get-WGPackage Needs to recognize non-English results #1

Closed stevenbaert closed 2 years ago

stevenbaert commented 2 years ago

Hi,

First of all: great work guys!

I'm building small GUI on Winget with your wingettools.

Now Get-WGPackage seemed to work fine but suddenly stopped working. F.e. Get-WGPackage Firefox shows no output.

Found https://www.powershellgallery.com/packages/WingetTools/0.6.0/Content/functions%5CGet-WGPackage.ps1 but didn't help me with analysis.

Any idea howto troubleshoot? Thanks! Steven

jdhitsolutions commented 2 years ago

Hmm..... This works for me with no errors.

image

What version of PowerShell are you running? What version of the WingetTools module? The most recent version is 1.0.0.

jdhitsolutions commented 2 years ago

You could also try running the native Winget command.

winget show --name firefox --source winget

And see what you get.

stevenbaert commented 2 years ago

Thanks, Winget is working fine. But wingettools via search Firefox | get-wgpackage converts it to a powershell object and that's exactly what I need to list the result in a gridview. That suddenly stopped working and then I noticed that the get-wgpackage didn't give output.

I did update software via Winget on my Windows 10 machine, maybe some dependency broke? Note that I do have output via get-wgpackage Firefox but the lines - it lists several- below headings (name, id , version etc) are empty.

jdhitsolutions commented 2 years ago

What version of winget are you using?

winget --version

And what is the exact command you are trying to run?

stevenbaert commented 2 years ago

I did install Winget via wingettools today, so I assume Winget is the latest version(?)

I have a textbox which contains the item to search for in value $textbox I first do a $result = get-wgpackage $textbox.text | out-gridview -passthrough Then the selection in the gridview is passed to Winget install $result.id But the gridview suddenly appeared empty :-( Then I saw the command is also empty when running get-wgpackage firefox

I have it on both a production system as well as a vanilla w10 system to which I install prereqs (wingettools, nuget, winget etc). No clue why it suddenly stopped working.

jdhitsolutions commented 2 years ago

On a new Win10 system I can do this: image

I can also pipe the command to Out-Gridview. At a prompt run:

Get-WGPackage Firefox -verbose

and paste the verbose output. That might help show where things are breaking down.

stevenbaert commented 2 years ago

Thanks for your input! Really strange, but I fail to reproduce the issue now. Have several W10 machines to test with but none of them has the issue now. I'll have to test things again and hopefully can reproduce to update this item and find root cause.

jdhitsolutions commented 2 years ago

I suppose it could have been a back-end problem with the package repository. I'll leave this issue open for now.

stevenbaert commented 2 years ago

I could reproduce on another (company build) system. Might be related to that system (on which it worked before). Below the output. As you can see the output is empty.

PS C:\WINDOWS\system32> get-wgpackage firefox -Verbose VERBOSE: [16:08:13.1092192 BEGIN ] Starting Get-WGPackage VERBOSE: [16:08:13.1517023 BEGIN ] Using source winget VERBOSE: [16:08:13.1517023 BEGIN ] Using Parameter set name VERBOSE: [16:08:13.1517023 PROCESS] Invoking: winget show --source winget --name 'firefox' VERBOSE: [16:08:15.0580108 PROCESS] Converting winget data VERBOSE: Gevonden Mozilla Firefox [Mozilla.Firefox] Versie: 96.0.3 Uitgever: Mozilla URL van uitgever: https://www.mozilla.org/en-US/ Ondersteunings-URL van uitgever: https://support.mozilla.org/en-US/ Auteur: Mozilla Foundation Koppelingspad: firefox Beschrijving: Firefox Browser, also known as Mozilla Firefox or simply Firefox, is a free and open-source web browser developed by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. Firefox uses the Gecko layout engine to render web pages, which implements current and anticipated web standards. In 2017, Firefox began incorporating new technology under the code name Quantum to promote parallelism and a more intuitive user interface. Firefox is officially available for Windows 7 or newer, macOS, and Linux. Its unofficial ports are available for various Unix and Unix-like operating systems including FreeBSD, OpenBSD, NetBSD, illumos, and Solaris Unix. Startpagina: https://www.mozilla.org/en-US/firefox/ Licentie: Mozilla Public License Version 2.0 Licentie-URL: https://www.mozilla.org/en-US/MPL/2.0 Privacy-URL: https://www.mozilla.org/en-US/privacy/websites Copyright-URL: https://www.mozilla.org/en-US/foundation/trademarks/policy Opmerkingen bij de release: Fixed an issue that allowed unexpected data to be submitted in some of our search telemetry (bug 1752317)

URL voor opmerkingen bij de release: https://www.mozilla.org/en-US/firefox/96.0.3/releasenotes/ Installatieprogramma: Type: Msix Download-URL: https://download-installer.cdn.mozilla.net/pub/firefox/releases/96.0.3/win64/multi/Firefox%20Setup%2096.0.3.msix SHA256: 449b02744455d86692c4eea0aabbb268ced75d54cc45772cfe2bc3cdc6659422 Releasedatum: 2022-01-26 VERBOSE: [16:08:15.0580108 CONVERT] Processing package data VERBOSE: [16:08:15.0892598 CONVERT] Creating object

Name ID Version Description


VERBOSE: [16:08:15.1048852 END ] Ending Get-WGPackage

jdhitsolutions commented 2 years ago

This helps. At least I can see that winget is getting the package. Now I need to see what the package data isn't getting properly processed by the function.

jdhitsolutions commented 2 years ago

I wonder if there is a culture problem with the output from winget and my parsing function. Can you run winget show --name firefox --source winget | out-file winget-firefox.txt and attach the text file? That will give me something to test with.

jdhitsolutions commented 2 years ago

Yeah, I found at least one problem already with the regex patterns where I made the silly assumption winget output would always be in Engilish.

jdhitsolutions commented 2 years ago

Definitely, a language issue that is going to be complicated to resolve.

stevenbaert commented 2 years ago

Thanks for the input. Could I (temporarily) force the output to English? That would be fine for me as a workaround.

jdhitsolutions commented 2 years ago

This is apparently a known problem with Microsoft Store apps which, I think Winget is using behind the scenes. In my research, I found a reference to https://docs.microsoft.com/en-us/powershell/module/international/set-winuserlanguagelist?view=windowsserver2019-ps which might solve the problem. You might be able to add English. I tried adding NL-NL. Or you would need a system running the En-US culture.

I think I have a fix for the function. The challenge is the custom formatting file which assumes English. I'm not sure how to handle that yet.

stevenbaert commented 2 years ago

Thanks! I ll look into it. If I can make it work, I ll let you know the details.

stevenbaert commented 2 years ago

This works for me as a quickfix:

$OriginalLangList = Get-WinUserLanguageList Set-WinUserLanguageList en-BE -Force -ErrorAction SilentlyContinue get-wgpackage firefox Set-WinUserLanguageList -LanguageList $OriginalLangList -Force

jdhitsolutions commented 2 years ago

That should work for the native winget command. The problem is that the Get-WGPackage is trying to parse and format the native output. The function is building a custom object based on the output. The challenge is that the property names of the object you create are different than what I create. That's the work I have to figure out.

jdhitsolutions commented 2 years ago

There is no easy fix on my part. Winget is inconsistent in the data that it returns so it is next to impossible to create a consistent object. Then we have the language issue. I think the best I can do is add some clarity to the documentation and recommend the WinUserLanguage workaround.

Can you run this and post the result:

Get-Culture
Get-UiCulture
$OriginalLangList = Get-WinUserLanguageList
Set-WinUserLanguageList en-BE -Force -ErrorAction SilentlyContinue
get-wgpackage firefox -verbose  |  Select *
Set-WinUserLanguageList -LanguageList $OriginalLangList -Force

It may be easiest to start a transcript, run the commands, then post the file. This will help with my documentation and help me better understand what is happeining.

stevenbaert commented 2 years ago

Sorry, didn't see reply. Will check & update post.

jdhitsolutions commented 2 years ago

Closing the issue as stale but will happily re-open.