-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set pwsh PSNativeCommandUseErrorActionPreference
#8900
Comments
shouldn't it be done on Windows (or Powershell) level ? |
technically, it's a breaking change in a wide world, that's why it's a new opt-in setting.
That's not entirely correct, see docs:
|
Hello @vaind . Unfortunately we cannot enable this feature because current installed PowerShell version (7.2.16) doesn`t support those.
But, as you say, this setting will default to enabled on Powershell 7.4 . I am closing this issue for now, but if you have additional questions, feel free to ask. |
It seems that the setting ended up being defaulted to "false", not "true", so this issue is still valid (at least as of pwsh 7.4.5). IMO it makes sense to force PSNativeCommandUseErrorActionPreference to not only unify behavior with unix shells, but also to match the clear fail-fast behavior intention that is mentioned in the docs linked by @vaind:
Which could now of course read:
This behavior seems intuitive in the context of CI/CD, especially since again, bash and sh already function this way when used through GitHub Actions as shown in the above documentation. |
Description
There have been multiple issues asking to change the behavior of
pwsh
to respect executables exit codes. Since pwsh v7.3, there's a new setting to do exactly what other shells do:PSNativeCommandUseErrorActionPreference
. This has become mainstream in pwsh v7.4: https://learn.microsoft.com/en-us/powershell/scripting/learn/experimental-features?view=powershell-7.4#psnativecommanderroractionpreferenceOne of the issues that this has come up before:
Depends on updating pwsh: #8847
Platforms affected
Runner images affected
Image version and build link
https://github.com/getsentry/sentry-unity/actions/runs/6999733486/job/19047630987
Is it regression?
no
Expected behavior
(Native) executable errors should propagate and fail the step, the same way they would on other shells.
Docs already indicate they should: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
Actual behavior
Errors let the step script continue as if nothing has happened, leading to an incorrect CI execution.
This partially works if there's a single command, because that one will get its exit code propagated
Repro steps
create a multiline run step, the first shell command failing, the second one passing (zero exit code)
The text was updated successfully, but these errors were encountered: