Powershell: Regression: native app doesn't run in parens on Linux

Created on 12 Aug 2020  路  5Comments  路  Source: PowerShell/PowerShell

Steps to reproduce

On Linux run

(date)

Expected behavior

Outputs the current date/time

Tue Aug 11 18:57:14 MDT 2020

Actual behavior

Fails with a weird ResourceUnavailable error:
image

Environment data

Name                           Value
----                           -----
PSVersion                      7.1.0-preview.5
PSEdition                      Core
GitCommitId                    7.1.0-preview.5
OS                             Linux 4.4.0-19041-Microsoft #1-Microsoft Fri Dec 06 14:06:00 PST 2019
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

This works fine on Windows. Execute (git --version) and the Git version is output.

Here's the full error info:

Exception             : System.Management.Automation.ApplicationFailedException: Program 'date' failed
                         to run: The operation is not allowed on non-connected sockets.At line:1 char:
                        29
                        + $PSVersionTable.PSVersion; (date); Get-Error
                        +                             ~~~~.
                         ---> System.IO.IOException: The operation is not allowed on non-connected soc
                        kets.
                           at System.Net.Sockets.NetworkStream..ctor(Socket socket, FileAccess access,
                         Boolean ownsSocket)
                           at System.Diagnostics.Process.OpenStream(Int32 fd, FileAccess access)
                           at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
                           at System.Diagnostics.Process.Start()
                           at System.Management.Automation.NativeCommandProcessor.InitNativeProcess()
                        in /PowerShell/src/System.Management.Automation/engine/NativeCommandProcessor.
                        cs:line 466
                           --- End of inner exception stack trace ---
                           at System.Management.Automation.NativeCommandProcessor.InitNativeProcess()
                        in /PowerShell/src/System.Management.Automation/engine/NativeCommandProcessor.
                        cs:line 597
                           at System.Management.Automation.NativeCommandProcessor.Prepare(IDictionary
                        psDefaultParameterValues) in /PowerShell/src/System.Management.Automation/engi
                        ne/NativeCommandProcessor.cs:line 305
                           at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary
                        psDefaultParameterValues) in /PowerShell/src/System.Management.Automation/engi
                        ne/CommandProcessorBase.cs:line 442
                           at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean in
                        comingStream) in /PowerShell/src/System.Management.Automation/engine/pipeline.
                        cs:line 1051
                           at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecu
                        teEnumerate(Object input) in /PowerShell/src/System.Management.Automation/engi
                        ne/pipeline.cs:line 499
                        --- End of stack trace from previous location ---
                           at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecu
                        teEnumerate(Object input) in /PowerShell/src/System.Management.Automation/engi
                        ne/pipeline.cs:line 585
                           at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Bo
                        olean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[]
                         pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext
                        funcContext) in /PowerShell/src/System.Management.Automation/engine/runtime/Op
                        erations/MiscOps.cs:line 493
                           at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(Int
                        erpretedFrame frame) in /PowerShell/src/System.Management.Automation/engine/in
                        terpreter/CallInstruction.Generated.cs:line 608
                           at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction
                        .Run(InterpretedFrame frame) in /PowerShell/src/System.Management.Automation/e
                        ngine/interpreter/ControlFlowInstructions.cs:line 358
                           at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction
                        .Run(InterpretedFrame frame) in /PowerShell/src/System.Management.Automation/e
                        ngine/interpreter/ControlFlowInstructions.cs:line 358
TargetObject          :
CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
FullyQualifiedErrorId : NativeCommandFailed
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}
Issue-Question Resolution-Fixed Waiting - DotNetCore

Most helpful comment

@rkeithhill Are you using WSL1 or WSL2?

I can repro this on Ubuntu 18.04 (WSL1) with 7.1.0-preview.5, but cannot repro it with 7.1.0-preview.3. This means it's a regression in recent release of .NET 5.0 preview. And FYI, I cannot repro the issue with 7.1.0-preview.5 on a standalone Ubuntu 16.04 machine.

Basically, the error is triggered by redirecting the stdout or stderr of a process. I will open an issue in dotnet/runtime.
[update] Here is the dotnet issue: https://github.com/dotnet/runtime/issues/40727

All 5 comments

It looks like .Net 5.0 Preview issue.

/cc @SteveL-MSFT @daxian-dbw for information.

@rkeithhill Are you using WSL1 or WSL2?

I can repro this on Ubuntu 18.04 (WSL1) with 7.1.0-preview.5, but cannot repro it with 7.1.0-preview.3. This means it's a regression in recent release of .NET 5.0 preview. And FYI, I cannot repro the issue with 7.1.0-preview.5 on a standalone Ubuntu 16.04 machine.

Basically, the error is triggered by redirecting the stdout or stderr of a process. I will open an issue in dotnet/runtime.
[update] Here is the dotnet issue: https://github.com/dotnet/runtime/issues/40727

I'm running WSL version1 for this Ubuntu instance:

08-10 12:55:42 6> wsl -l -v
  NAME                   STATE           VERSION
* Ubuntu                 Running         1

I guess .Net fix is expected in .Net 5.0 RC1.

Validated this works in WSL with 7.1-rc1

Was this page helpful?
0 / 5 - 0 ratings