Skip to content

Route the last direct pwsh spawns through the shared runner - #11303

Merged
danielhanchen merged 1 commit into
mainfrom
fix/pwsh-shared-runner-compiler-watch
Sep 18, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/pwsh-shared-runner-compiler-watch

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

The failure

Repo tests (CPU, studio) is red on main:

FAILED tests/studio/test_pwsh_calls_use_the_shared_runner.py::TestEveryPwshCallUsesTheSharedRunner::test_no_test_file_spawns_powershell_directly
1 failed, 11265 passed, 259 skipped

Reproduced locally on origin/main: 1 failed, 5 passed.

Seven call sites across two files start PowerShell with subprocess.run instead of run_pwsh, so they share one $XDG_CACHE_HOME/powershell startup cache with every other xdist worker and can die at startup with Stack overflow. or System.IO.FileLoadException: The given assembly name was invalid.

File Lines
tests/python/test_compiler_watch_temp_scan.py 72, 202, 237
tests/test_studio_install_workspace_guard.py 419, 461, 467, 520

Three of those are mine. I added test_compiler_watch_temp_scan.py in #11280 without reading the guard that was already there, so this is my regression, not a pre-existing one I happened to find.

The fix

run_pwsh takes the argv the call site already built and only redirects pwsh's own startup cache, so each site is a one-word change and no invocation flags move. The launcher case at test_studio_install_workspace_guard.py:520 keeps its explicit env, which run_pwsh extends rather than replaces, so the hermetic environment that test builds is preserved.

No test assertion is changed, and the guard is not touched or widened: the point is to satisfy it, not to quiet it. _ALLOWED_DIRECT_PWSH_CALLS exists for call sites that really are safe, and none of these seven qualifies -- they all hand the child the ambient HOME.

Verification

  • tests/studio/test_pwsh_calls_use_the_shared_runner.py: 6 passed (was 1 failed, 5 passed on main).
  • The two converted files: 120 passed, 1 skipped.
  • ruff check clean on all three files.

tests/studio/test_pwsh_calls_use_the_shared_runner.py is red on main. Seven call sites
in two files start PowerShell with subprocess.run instead of run_pwsh, so they share one
$XDG_CACHE_HOME/powershell startup cache with every other xdist worker and can die at
startup with `Stack overflow.` or `System.IO.FileLoadException`.

Three of them are mine, from #11280. The guard predates that PR and I added the file
without reading it.

run_pwsh takes the argv the call site already built and only redirects pwsh's own startup
cache, so each of the seven is a one-word change with no invocation flags moved. The
launcher case in test_studio_install_workspace_guard.py keeps its explicit `env`, which
run_pwsh extends rather than replaces.

tests/studio/test_pwsh_calls_use_the_shared_runner.py: 6 passed.
The two converted files: 120 passed, 1 skipped.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-18T20:31:08.357201Z 8323387 Manual request
🔒 Security Review ✅ Completed 2026-09-18T20:31:44.952647Z 8323387 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 8323387b88

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 8323387b88

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@danielhanchen
danielhanchen merged commit bbe4803 into main Sep 18, 2026
24 of 28 checks passed
@danielhanchen
danielhanchen deleted the fix/pwsh-shared-runner-compiler-watch branch September 18, 2026 22:17
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…i#11303)

tests/studio/test_pwsh_calls_use_the_shared_runner.py is red on main. Seven call sites
in two files start PowerShell with subprocess.run instead of run_pwsh, so they share one
$XDG_CACHE_HOME/powershell startup cache with every other xdist worker and can die at
startup with `Stack overflow.` or `System.IO.FileLoadException`.

Three of them are mine, from unslothai#11280. The guard predates that PR and I added the file
without reading it.

run_pwsh takes the argv the call site already built and only redirects pwsh's own startup
cache, so each of the seven is a one-word change with no invocation flags moved. The
launcher case in test_studio_install_workspace_guard.py keeps its explicit `env`, which
run_pwsh extends rather than replaces.

tests/studio/test_pwsh_calls_use_the_shared_runner.py: 6 passed.
The two converted files: 120 passed, 1 skipped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant