Skip to content

fix(wsl): run wsl.exe probes from the system folder, never the profile - #29853

Merged
nwparker merged 3 commits into
mainfrom
fix/wsl-probe-neutral-cwd
Oct 17, 2026
Merged

nwparker merged 3 commits into
mainfrom
fix/wsl-probe-neutral-cwd

Conversation

@nwparker

@nwparker nwparker commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​83 $\color{#cf222e}{\Huge{\mathbf{−}}}$​103 $\color{#cf222e}{\Huge{\mathbf{−}}}$​20
Prod 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​39 $\color{#cf222e}{\Huge{\mathbf{−}}}$​33 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​6

ELI5

On Windows, Orca asks WSL questions (which Linux distros are running, where git lives, and so on) by running wsl.exe. Each wsl.exe has to be started from some Windows folder. Orca was starting it from its own profile folder. WSL then keeps that folder in use for about a minute after the question is answered, so the profile folder can't be deleted during that minute. Orca now starts wsl.exe from the Windows system folder (C:\Windows), which nobody ever needs to delete.

What Changed

Before: an orca serve run with a temporary profile on a Windows machine that has WSL left a profile folder that could not be deleted for about 60 seconds after serve exited ("resource busy or locked"). On Windows ARM CI this failed the serve-parity test, until #29845 made the test wait out the minute.

After: wsl.exe never runs from a profile or user folder, so the profile folder can be deleted as soon as Orca exits.

Mechanism:

  • resolveWslInteropSpawnCwd() (the shared "which folder should wsl.exe start in" answer) used to prefer ORCA_USER_DATA_PATH (the profile), then USERPROFILE/home. It now picks %SystemRoot%, then %windir%, %SystemDrive%\, and C:\. Every caller of the helper changes with it, including the running-distro probe that fix(orcad): orca serve owns its Claude and Codex accounts again #29209's account service runs at orcad startup, the WSL availability check, the git runner, the hook relay, the file watcher, and the \\wsl$ delete path.
  • The Codex WSL usage probe (codex-fetcher.ts) started wsl.exe in <profile>/rate-limit-pty-cwd. The WSL branch now uses the helper. The guest side already cds to its own temp folder, so nothing inside Linux changes. The host Codex branch keeps its bounded folder.
  • Probes that passed no directory at all (so they inherited Orca's own) now name the helper's directory: the WSL guest-environment probe, the WSL git read-environment probe, the Codex trust-grant identity probe, the Codex WSL hook path canonicalization, the Codex managed-home path check, and the Codex backfill-recovery app server.
  • Reverts test(orcad): wait out the WSL service hold on a serve-parity profile #29845's extended EBUSY wait in the serve-parity test. That wait is no longer needed, and dropping it makes the test catch the hold again: a held profile outlasts the normal ~45s removal budget.

Argv building is unchanged (buildWslExecArgs etc.). Only the Windows working directory handed to CreateProcessW changed.

Why

#29845's investigation traced the hold here. It started when #29209 merged. It only happens on runners where the startup probe runs wsl.exe. It outlives every process in the test's tree, and it lasts about as long as WSL's idle timeout. wsl.exe turns its Windows working directory into the Linux starting directory (/mnt/c/...), and WSL keeps that open until the instance idles.

Alternatives considered:

  • Keep waiting in tests (test(orcad): wait out the WSL service hold on a serve-parity profile #29845): this hides a real user-facing problem. Users can't delete a profile either.
  • A dedicated empty folder under temp or the profile: it would still be a user-owned folder that someone may want to delete, and it would have to be created and kept alive.
  • Pass --cd ~ to wsl.exe: this changes the Linux side's directory only. The Windows-side working directory is still handed to CreateProcessW, so that is still the folder held.

The system folder always exists, is never deleted, and is the directory Windows services start in. It also keeps #16463's guarantee that wsl.exe never inherits a deleted \\wsl.localhost\... directory. All of these commands already carry their Linux directory explicitly (git -C, cd inside sh -c), so none of them relied on the starting folder.

Linked Issue

N/A (maintainer fix). Root cause found in #29845. Regression from #29209.

Visual Proof

N/A. This changes the background process working directory, with no UI.

Testing

  • src/main/wsl-interop-spawn-directory.test.ts: the helper names the system root even when the profile and the user folder exist, never falls back to either, skips a missing candidate, and re-validates its memo.

  • src/main/wsl-running-distros.test.ts: the startup wsl --list --running probe runs with cwd set to the system root, not the profile.

  • codex-fetcher.test.ts, wsl.test.ts, wsl-runner.test.ts, wsl-unc-delete.test.ts now assert the exact neutral directory.

  • Windows CI: orcad-serve-parity.integration.test.ts runs without the 75s hold on windows-11-arm. Results across repeated runs are in the comments below.

  • pnpm tc:node, check:code-quality:changed, and vitest on src/main/{wsl,git,gitlab,codex,codex-accounts,claude-accounts,rate-limits,agent-hooks,daemon,ipc,providers,ai-vault,opencode,native-chat,text-generation} pass locally on macOS. The only failures are the browser-manager suites, which need ORCA_BACKGROUND_LAUNCH=1 and fail on main too.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: C:\Windows is only writable by admins, so it is a safer working directory than a user-writable profile.
  • Cross-platform: only Windows spawns wsl.exe. On macOS and Linux the helper's answer is unused.
  • SSH/remote: no change. These are local wsl.exe spawns.
  • WSL with automount disabled: C:\Windows can't be translated to a Linux path, but neither could the profile path before, so behavior there is unchanged.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

WSL holds wsl.exe's working directory busy for about its idle timeout
after the probe exits. Since #29209 the orcad startup probe ran in the
profile, so a temporary orca serve profile could not be deleted for about
a minute (diagnosed in #29845).
Reverts #29845's extended EBUSY retry: wsl.exe no longer runs in the
profile, so nothing outside the test's process tree holds it.
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 36bdee7b-732c-42ec-93c8-e7c32f999255
📥 Commits

Reviewing files that changed from the base of the PR and between 4e12343 and 11e03ff.

📒 Files selected for processing: 1
  • config/tsconfig.cli.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

📝 Walkthrough

WSL subprocesses now use a working directory selected from system directories, with tmpdir() as the final candidate and undefined when no candidate exists. The affected WSL probes pass this directory when spawning; non-WSL rate-limit probes retain their existing working directory. Test-root removal no longer extends Windows EBUSY retries beyond the existing attempt limit.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 11e03

No concrete merge-blocking regression is established. The cwd-isolation concern depends on fallback conditions not shown to occur in supported Windows launches.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 31.25% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 16 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: running WSL probes from the system folder instead of a user profile.
Description check Passed The description is complete and follows the required template. It explains the problem, implementation, rationale, testing, platform impact, and maintainer-specific issue exception. It also documents …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is complete and follows the required template. It explains the problem, implementation, rationale, testing, platform impact, and maintainer-specific issue exception. It also documents known unrun or failing checks.

Full details: Docstring Coverage

Explanation

Docstring coverage is 31.25% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 16 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker

Copy link
Copy Markdown
Contributor Author

CI evidence that the profile hold is gone (and #29845's wait can go)

persistence (windows-11-arm) ran 8 times on this branch with the 75s hold removed: the 2 PR runs plus 6 reruns of run 38976432781.

  • All 8 passed.
  • Every run logged the orcad startup probe's wsl.exe exited with 1, the condition that used to trigger the hold.
  • None logged EBUSY.
  • The "prints only the recipe line" case took 4.9 to 11.4s across runs. A held run took about 60s.

Before this change, 11 of 30 runs failed on the hold (#29845). Eight clean runs in a row would happen about 1% of the time if the hold were still there (0.55^8).

The real-distro lanes also passed (WSL2 distros (systemd off and on), real WSL terminal). They run git and terminals through wsl.exe, so they cover the new working directory against real distros.

@nwparker
nwparker merged commit 0ed0caa into main Oct 17, 2026
156 of 158 checks passed
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