pwsh (PowerShellV2) tries to spawn powershell.exe process inside container with PowerShell Core
See original GitHub issueType: Bug Task Name: pwsh (PowerShellV2)
Environment
Server
Azure DevOps Server Version 17.143.28912.1
Agent
Type: Private OS: Windows Server 1809 with Docker Version: vsts-agent-win-x64-2.144.2
Issue Description
I run pwsh
task inside a mcr.microsoft.com/powershell:6.2.3-nanoserver-1809
container and get failure mentioning that node.js
cannot spawn C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
process.
I wonder why pwsh
task needs to run powershell.exe
process?
YAML definition excerpt
container:
image: mcr.microsoft.com/powershell:6.2.3-nanoserver-1809
steps:
- pwsh: |
# Inline script
Task logs
2019-09-27T11:17:12.7725567Z ==============================================================================
2019-09-27T11:17:12.7725614Z Task : PowerShell
2019-09-27T11:17:12.7725642Z Description : Run a PowerShell script on Windows, macOS, or Linux.
2019-09-27T11:17:12.7725676Z Version : 2.140.2
2019-09-27T11:17:12.7725702Z Author : Microsoft Corporation
2019-09-27T11:17:12.7725730Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613736)
2019-09-27T11:17:12.7725767Z ==============================================================================
/* ... */
2019-09-27T11:17:13.0712078Z events.js:160
2019-09-27T11:17:13.0712509Z throw er; // Unhandled 'error' event
2019-09-27T11:17:13.0712639Z ^
2019-09-27T11:17:13.0714281Z
2019-09-27T11:17:13.0720062Z Error: spawn C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe ENOENT
2019-09-27T11:17:13.0723425Z at exports._errnoException (util.js:1018:11)
2019-09-27T11:17:13.0723712Z at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
2019-09-27T11:17:13.0723870Z at onErrorNT (internal/child_process.js:367:16)
2019-09-27T11:17:13.0723990Z at _combinedTickCallback (internal/process/next_tick.js:80:11)
2019-09-27T11:17:13.0724113Z at process._tickCallback (internal/process/next_tick.js:104:9)
2019-09-27T11:17:13.1880286Z ##[error]Exit code 1 returned from process: file name 'C:\Program Files\Docker\docker.EXE', arguments 'exec -i 75c31673282e4f2396b2b1c44e37e07a683a7ad0e248aacbc0eaaf084541377d C:\__a\externals\node\bin\node.exe C:\__w\_temp\containerHandlerInvoker.js'.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Start-Process (Microsoft.PowerShell.Management)
To specify the program that runs in the process, enter an executable file or script file, or a file that can be opened...
Read more >Powershell equivalent of bash ampersand (&) for forking ...
The following command contains basic usage of the ampersand background operator. Get-Process -Name pwsh &. This is functionally equivalent to the following ...
Read more >How to run PowerShell Core scripts from .NET Core applications
NET process. We call the .AddScript() and .AddParameters() methods to pass our input, and then call .InvokeAsync() to execute the pipeline.
Read more >Windows Container build fails without an error message
0\powershell.exe ENOENT at exports._errnoException (util.js:1018:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32) at ...
Read more >PowerShell - Wikipedia
PowerShell is a task automation and configuration management program from Microsoft, ... on 18 August 2016 with the introduction of PowerShell Core.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I actually have a PR to fix this in the agent itself. https://github.com/microsoft/azure-pipelines-agent/pull/2767
The problem is that our task model uses either a Node or PowerShell handler to run the task, not PowerShell Core. On Windows, we always prefer the PowerShell handler, but in this case, there is no PowerShell in the container, only PowerShell Core.
The powershell task itself should work. I would expect the commandline task to fail, though, since it would run its Node Handler Linux version which looks for bash.