runner
runner copied to clipboard
The default shell for Windows (Powershell) does not show the stderr/stdout on exit error
Describe the bug
For example, this build my which used the default shell for windows (powershell), did not showed the stdout or stderr of the error. It just says the command exited with some error code. Doing so, you have no ideia from which line the error comes from or what was happening: https://github.com/evandroforks/anki/runs/522520124?check_suite_focus=true#step:5:10
This problem does not happens if I change the shell to cmd
: https://github.com/evandroforks/anki/runs/522428852?check_suite_focus=true#step:5:26
Question, Bug, or Feature?: "Bug"
Virtual environments affected
- [ ] macOS 10.15
- [ ] Ubuntu 16.04 LTS
- [ ] Ubuntu 18.04 LTS
- [x] Windows Server 2016 R2
- [x] Windows Server 2019
It's something to do with the new error view in PowerShell 7.
Try adding $ErrorView = "NormalView"
at the top of the script
Hello @evandrocoan , thank you for the detailed report. This repository manages only content of Hosted images for GA and AzDO, not the build running process. For me, it looks like the issue with actions/runner.
@TingluoHuang , @ericsciple , Hello! Does it make sense to move this issue to your repository for further investigation?
@dakale
The runner captures all output from the shell processes it runs and prints them to the console. In your example it looks like you are comparing two different steps: The first one using pwsh
is "Fix choclately install" and the cmd
step is "Set up ripgrep ... ", so I would expect them to have different outputs.
Are you sure the first step is supposed to be outputting anything?
I am certain Powershell never ever tells me when there is an error. It made my life hell for countless occasions. I will never ever use Powershell again with GitHub actions. They are just not worth. This was not the only case. Running the same commands locally on my computer, Powershell is quite verbose about their errors:
Instead of using Powershell directly, I can just set the shell to cmd
and invoke Powershell from it, as I am doing on this rule, on the latest version of that script: https://github.com/evandroforks/anki/actions/runs/62292014/workflow#L101-L106
- name: Set up scoop, gettext, ripgrep
shell: cmd
run: |
echo on
powershell -executionpolicy bypass "& Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')"
scoop install -g gettext ripgrep
@hbuckle wrote:
It's something to do with the new error view in PowerShell 7. Try adding
$ErrorView = "NormalView"
at the top of the script
That did it for me! Thanks! :smile:
As per the MS docs, $ErrorView
is now defaulted to ConciseView
. As @hbuckle suggested, I simply added:
$ErrorView = 'NormalView'
And now get the more detailed output I'd expected.
@pcolby Thanks for reporting back! @alepauly, this $ErrorView = 'NormalView'
should be the default value because it is quite frustrating having PowerShell hiding from you what went wrong.
@ericsciple @dakale should we set $ErrorView = 'NormalView'
when we generate the .ps1
script?
$ErrorView = 'NormalView'
Is it possible to set this for all pwsh invocations in a given workflow file? (explicit use of pwsh
or by OS default)
Is it possible to set this for all pwsh invocations in a given workflow file? (explicit use of pwsh or by OS default)
I'd recommend setting a job level ENV for ErrorView
.
We have decided against modifying the powershell
default behaviour here. As a workaround, set the ErrorView ENV to NormalView or ConciseView on the job or step level, or directly in your script.ps1 file that you're executing.