ConsoleGuiTools
ConsoleGuiTools copied to clipboard
WSL - Unhandled Exception when executing Out-Gridview command
Description: In Windows Subsystem for Linux (WSL) the following exception occurs when executing the Out-Gridview command:
dir | select name | out-gridview
Exception message:
Unhandled Exception: System.TypeInitializationException: The type initializer for 'OutGridView.Application.AvaloniaAppRunner' threw an exception. ---> System.Exception: XOpenDisplay failed
at Avalonia.X11.AvaloniaX11Platform.Initialize(X11PlatformOptions options)
at Avalonia.Controls.AppBuilderBase`1.Setup()
at OutGridView.Application.AvaloniaAppRunner.BuildAvaloniaApp() in D:\a\1\s\src\OutGridView.Gui\AvaloniaAppRunner.cs:line 34
at OutGridView.Application.AvaloniaAppRunner..cctor() in D:\a\1\s\src\OutGridView.Gui\AvaloniaAppRunner.cs:line 31
--- End of inner exception stack trace ---
at OutGridView.Application.Program.Main(String[] args) in D:\a\1\s\src\OutGridView.Gui\Program.cs:line 26
Environment:
Windows 10: WSL 1 (Windows Build 1903) and 2 (Windows 10 Insider Build 18985) - Linux Ubuntu 18.04
PowerShell 7 Preview.4
Microsoft.PowerShell.GraphicalTools v 0.2.0
WSL will have to be special cased. It's the only scenario where we want the Windows code path to fire when we run within Linux.
Since WSL has no screen, this exception is expected. However, thanks to WSL being able to launch Winoows processes, we can take advantage of that to get this feature.
I've seen some blog posts (not from Msft) on enabling x-windows on WSL which could make this work, but this is really outside the scope of this module for now.
@SteveL-MSFT
Yes! But it only works on WSL-1 and not for the insider edition WSL-2. I think this is due to the fact that it uses a VM (at least is my understanding).
@MaximoTrinidad yeah, that makes sense since WSL-1 was going through the NT Kernel and effectively was a Windows app while WSL-2 is a VM. I don't see this being supported in WSL-2.
@SteveL-MSFT
I just hope that in the future will work. I'll keep praying for it!
:)
Please feel free to close this issue if the bottom line is that won't be supported. Thanks!
The can be addressed as a feature. We just need to test for WSL and launch the Windows exe instead of the linux exe as that should work. Not sure if PassThru will work though.
@TylerLeonhardt
As a Feature for WSL-2! That would be nice.
Keep in mind! It works in WSL-1 Windows 10 RTM with Windows Xserver. This is Great!!
The Windows Subsystem For Linux Preview natively provides an X-server, so this remains important.
@andschwa This should be closed as won't fix since it's for the Avalona version.