Skip to content

[ci] Avoid macOS PowerShell startup failures - #13709

Merged
jonathanpeppers merged 1 commit into
mainfrom
simonrozsival-powershell-ci-recovery
Nov 23, 2026
Merged

jonathanpeppers merged 1 commit into
mainfrom
simonrozsival-powershell-ci-recovery

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Context: #12652
Context: dotnet/maui#35724
Context: PowerShell/PowerShell#20802

PowerShell intermittently exits before running CI scripts on macOS with Call to 'procargs' failed with errno 5. Its login-shell detection treats a failed sysctl call as a fatal startup error, causing unrelated pipeline steps to fail.

Set __PWSH_LOGIN_CHECKED=1 in the shared CI variables, following MAUI's workaround, to skip the login-shell check for PowerShell task processes. PowerShell consumes this internal variable at startup, so nested PowerShell processes are not protected unless it is set again.

Validation:

  • ruby -e 'require "yaml"; d = YAML.load_file(ARGV[0]); v = d.fetch("variables").select { |x| x["name"] == "__PWSH_LOGIN_CHECKED" }; abort "incorrect variable" unless v == [{"name" => "__PWSH_LOGIN_CHECKED", "value" => "1"}]; puts "PASS: YAML parses and sets __PWSH_LOGIN_CHECKED to 1"' build-tools/automation/yaml-templates/variables.yaml — passed.
  • With a local sysctl fault injector compiled to $work/interpose.dylib, env -u __PWSH_LOGIN_CHECKED DYLD_INSERT_LIBRARIES="$work/interpose.dylib" SYSCTL_INJECT_PROCARGS_ERRNO=5 pwsh -NoLogo -NoProfile -NonInteractive -Command 'Write-Output STARTED' reproduced the startup failure; env __PWSH_LOGIN_CHECKED=1 DYLD_INSERT_LIBRARIES="$work/interpose.dylib" SYSCTL_INJECT_PROCARGS_ERRNO=5 pwsh -NoLogo -NoProfile -NonInteractive -Command 'Write-Output STARTED' succeeded.
  • git diff --check — passed.

The full Azure Pipelines run was not executed locally.

Set __PWSH_LOGIN_CHECKED for CI tasks to skip the PowerShell login-shell check, following the MAUI workaround for intermittent procargs errno 5 failures on macOS.

Context: #12652
Context: dotnet/maui#35724

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 22, 2026 10:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are identified for the shared Android CI PowerShell startup workaround.

No open issues 🎉

What changed in this PR

This PR updates shared .NET for Android CI configuration to avoid intermittent macOS PowerShell startup failures caused by procargs errors.

Changes:

  • Sets __PWSH_LOGIN_CHECKED='1' so PowerShell task processes skip the failing login-shell check.
  • Adds comments linking the Android issue and the equivalent MAUI workaround.
File Description
build-tools/​automation/​yaml-templates/​variables.yaml Adds the shared PowerShell startup workaround and context links.

Review effort: Balanced

@simonrozsival

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

✅ Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #13709

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: no blocking code findings; independent Azure CI verification is incomplete.

Reviewed the complete changed file and its pipeline consumers before reconciling the PR description. The shared variable template is included by the public, internal, nightly, and API-docs pipelines. The exact variable name and quoted value match dotnet/maui#35724, and PowerShell's AttemptExecPwshLogin() checks this marker before the macOS sysctl calls, clears it, and returns. This is a narrowly scoped workaround that avoids changing individual task definitions or product behavior.

Findings: 0 errors, 0 warnings, 1 non-blocking documentation suggestion, posted inline.

CI: All 39 returned GitHub checks completed successfully, including the aggregate dotnet-android check for Azure build 1693921 and the macOS lanes. The standalone Azure build-status query was rejected because the CLI requires authentication, so I could not independently confirm Azure's build result or timeline. No local macOS reproduction was performed in this Linux review environment; the PR's reported fault-injection results were not independently rerun.

Generated by Android PR Reviewer for #13709 · copilot · gpt61 · 21 AIC · ⌖ 7.5 AIC · ⊞ 20.3K
Comment /review to run again

value: 'TestCategory!=SystemApplication&TestCategory!=TimeZoneInfo&TestCategory!=Localization'
- name: RunMAUITestJob
value: true
# Avoid macOS PowerShell startup failures: https://github.com/dotnet/android/issues/12652

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 💡 Documentation — Consider adding the upstream PowerShell/PowerShell#20802 link and a short note that PowerShell clears this marker during startup. AttemptExecPwshLogin() removes it before returning, so this protects each task's initial PowerShell process, not nested pwsh processes unless they set it again. The PR description explains that limitation well; keeping it beside the workaround would preserve it for future pipeline changes.

{Rule: Comments explain why; document behavioral limitations}

@simonrozsival simonrozsival added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Nov 23, 2026
@jonathanpeppers
jonathanpeppers merged commit bea9ad7 into main Nov 23, 2026
39 checks passed
@jonathanpeppers
jonathanpeppers deleted the simonrozsival-powershell-ci-recovery branch November 23, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants