winget-cli: PowerShell ISE doesn't like WinGet

Corrupt characters in PowerShell ISE when running WinGet --help

Brief description of your issue

Run WinGet --help from PowerShell ISE elevated.

As above. Run WinGet --help or even winget visual azure in from PowerShell ISE elevated

Expected behavior

Fully readable text.

Actual behavior

Partly corrupt text. See attached screenshots.

Environment

[winget --info]
Windows Package Manager v0.1.41331 Preview
Windows: Windows.Desktop v10.0.19041.208
Package: Microsoft.DesktopAppInstaller v1.0.41331.0

Any other software? none.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 2
  • Comments: 15 (1 by maintainers)

Most upvoted comments

@doctordns Setting an ENVVAR for every command-line tool on the planet telling it whether or not to support VT is not a tenable solution? And how does winget running on a remote machine read the ENVVAR settings on your local Windows instance running ISE? Hint: it can’t, so now you have to go set ENVVARS on all the remote machines you connect to. And then when you operate the remote machine locally, winget doesn’t emit color … why? Because the ENVVAR tells it not to.

However … every other shell and terminal on the planet has supported VT since the '60s.

Heck, we even managed to get the venerable Windows Console to support VT (without breaking the world - we’re rather proud of that 😜). Windows Terminal supports a superset of the VT supported by Console. Every other 3rd party Windows terminal including ConEmu, Cmder, Console2, ConsoleZ, and Hyper all support VT.

The issue here isn’t winget emitting VT, it’s ISE not supporting VT at all. Alas, ISE is EOL unless you can convince @SteveL-MSFT to dedicate resources to update it. If he won’t, I encourage you to start learning/adopting tools that are actively developed and supported.

FWIW, in ISE as it stands, you’ll also see all manner of “garbage” if you ssh into a Linux box, etc. or curl https://wttr.in/ from within ISE: image

vs. Terminal: image

vs. VSCode’ s terminal panel image

vs. Visual Studio’s built-in terminal panel (mostly) get it right: image

The “easy” fix is to have winget emit plain text. Only use ANSI if you detect that the console or environment supports it.

I think what you are seeing are the ANSI escape sequences being used to highight and color the output.

The problem here is that command-line tools cannot accurately determine whether the terminal they’re connected to supports VT (or any other capability for that matter).

While feasible locally by calling GetConsoleMode() and checking the returned flags for ENABLE_VIRTUAL_TERMINAL_INPUT, this breaks down if, for example, calling a command-line app on a remote machine via ssh.

The best fix for this would be for ISE to improve its built-in terminal to at least parse and strip VT sequences, or better still, the parse and process VT sequences.

I suggest filing an issue in the PowerShell repo, but as pointed out above, note that ISE is no longer being developed and it’s likely you’ll get a WONTFIX.

As an alternative, I’d recommend using VSCode with the PowerShell add-in - it’s actively developed and regularly improved.

This issue can be closed since ISE will not receive anymore updates and its use of a custom conhost increases the chances of incompatibilities with 3rd party tools.