Cannot process the XML from the 'Output' stream of 'C:\WINDOWS\system32\wsl.exe': Name cannot begin with the '#' character
Opened this issue · 6 comments
I am running Invoke-WslCommand -Command myscript.sh
to execute a shell script and am getting the following error:
wsl : Cannot process the XML from the 'Output' stream of 'C:\WINDOWS\system32\wsl.exe': Name cannot begin with the '#' character, hexadecimal value 0x23. Line 1, position 6145.
At line:1 char:1
+ wsl pwsh -OutputFormat xml -EncodedCommand JABWAGUAcgBiAG8AcwBlAFAAcg ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SyntaxError: (C:\WINDOWS\system32\wsl.exe:String) [], XmlException
+ FullyQualifiedErrorId : ProcessStreamReader_CliXmlError
wsl : Cannot process the XML from the 'Output' stream of 'C:\WINDOWS\system32\wsl.exe': Data at the root level is invalid. Line 1, position 256.
At line:1 char:1
+ wsl pwsh -OutputFormat xml -EncodedCommand JABWAGUAcgBiAG8AcwBlAFAAcg ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SyntaxError: (C:\WINDOWS\system32\wsl.exe:String) [], XmlException
+ FullyQualifiedErrorId : ProcessStreamReader_CliXmlError
WSL PSVersionTable:
Name Value
---- -----
PSVersion 6.0.2
PSEdition Core
GitCommitId v6.0.2
OS Linux 4.4.0-17666-Microsoft #1000-Microsoft Fri May 04 15:01:00 PST 2018
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Windows PSVersionTable:
Name Value
---- -----
PSVersion 6.0.2
PSEdition Core
GitCommitId v6.0.2
OS Microsoft Windows 10.0.17666
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Hmm I never considered running a shell script.
PSWsl was made to run PowerShell inside of the wsl distros not a shell script.
That said, supporting running shell scripts as well is a reasonable feature request!
As a workaround, I bet you could do something like:
Invoke-WslCommand -Command "bash myscript.sh"
haven't tested it though.
Well PowerShell was designed to be able to call native commands. I can see that the shell script is getting executed (some logs come through) but then the error occurs.
Maybe I can try to capture the output of the shell script into a file and cat
that for a reproducible example. It doesn't happen when e.g. just executing -Command "echo hi"
.
@felixfbecker yes PowerShell was designed to call native commands but a shell script isn't a native command in the same sense that ls, ps and grep are.
I'm curious... are you able to run the shell script in a normal instance of pwsh? (rather than going through PSWsl)
steps:
ps/cmd> wsl
bash > pwsh
PS > ./myscript.sh
yes PowerShell was designed to call native commands but a shell script isn't a native command in the same sense that ls, ps and grep are.
Calling a shell script is the same as calling bash
and passing the script as a parameter, which is a native command, so I wouldn't expect it to behave any differently.
I'm curious... are you able to run the shell script in a normal instance of pwsh? (rather than going through PSWsl)
Yes, it works completely fine. I think something here must be wrong with the XML serialisation/deserialisation of the output that the script generates.
Yes, it works completely fine. I think something here must be wrong with the XML serialisation/deserialisation of the output that the script generates.
Very possible! Are you able to share an example script that causes this error?