Skip to content

fix(wsl): say why a silent WSL guest command failed - #34304

Merged
nwparker merged 3 commits into
mainfrom
fix/wsl-guest-diag-12262
Oct 27, 2026
Merged

nwparker merged 3 commits into
mainfrom
fix/wsl-guest-diag-12262

Conversation

@nwparker

@nwparker nwparker commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​23 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​21
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​44 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​33

ELI5

When a command Orca runs inside WSL failed without printing an error, Orca only said "WSL Ubuntu: command failed". That gives no clue what went wrong. Orca now shows WSL's own error message when there is one, or the exit code otherwise.

What Changed

  • Before: in the Claude account setup for WSL terminals, a guest command that exited non-zero with empty stderr produced WSL <distro>: command failed. When wsl.exe itself fails, it exits 0xFFFFFFFF and writes its error (for example Wsl/Service/0x80072747) to stdout, and that text was thrown away. The OpenCode WSL reader setup did the same.

  • After: the message uses stderr first, then timed out, then wsl.exe: <its own error> for the host-failure exit, then exited with code N.

  • Mechanism: a new describeWslProcessFailure() in src/main/wsl/wsl-process-failure.ts is used by:

    • the Claude WSL account router;
    • the OpenCode WSL reader setup;
    • the WSL CLI installer;
    • WSL file operations.

    The host-failure exit check and the UTF-16 NUL stripping now live there, and the git runner's existing wsl.exe host failure annotation reuses them.

Why

STA-12262 reports that every new Claude terminal and every session restore in WSL fails with exactly WSL Ubuntu: command failed. The real cause is not recorded anywhere. WSL itself is healthy (wsl.exe -d Ubuntu --exec /bin/true works). This PR doesn't claim a root-cause fix. It makes the next occurrence say why it failed, which is what the reporter asked for, so we can fix the actual cause.

Linked Issue

Refs #33917 (STA-12262). This makes the failure diagnosable. It doesn't close the issue.

Thanks @lkg1024 for the thorough report.

Visual Proof

N/A. Only error text changes, and only when stderr was empty.

Testing

  • I manually tested these changes locally

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

  • New case in claude-profile-wsl-router.test.ts:

    • a wsl.exe host failure (exit 0xFFFFFFFF, stdout Wsl/Service/0x80072747) reports WSL Ubuntu: wsl.exe: Wsl/Service/0x80072747;
    • a silent guest exit reports WSL Ubuntu: exited with code 3.
  • Both fail on main, which reports command failed.

  • Tests for every changed module pass, including wsl-host-failure, the WSL CLI installer, the OpenCode WSL reader setup and local-worktree-filesystem.

Review

Codex review and an independent review against the pinned base.

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

  • Platforms: Windows only in effect. Every path touched is a WSL path.
  • Callers: no caller matches on these message strings.
  • Exposure: guest stdout is shown only for the wsl.exe host-failure exit, which a Linux guest can't produce.
  • Mixed versions: no wire change.

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)

A guest command that exits non-zero with empty stderr was reported as
"WSL <distro>: command failed". When wsl.exe itself fails it writes its
error to stdout, so the real cause was dropped. Report stderr, else
wsl.exe's own error, else the exit code, for the Claude account pointer,
OpenCode reader, WSL CLI install and WSL file operations.

Refs STA-12262 (#33917)
@coderabbitai

coderabbitai Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bcca975d-77a1-4ef2-897e-e582c4ad2b1f
Commits

Reviewing files that changed from the base of the PR and between cbbaa2d and f0793c6.

Files selected for processing: 7
  • src/main/ai-vault/opencode-wsl-runtime-preparation.ts
  • src/main/claude-accounts/claude-profile-wsl-router.test.ts
  • src/main/claude-accounts/claude-profile-wsl-router.ts
  • src/main/cli/wsl-cli-installer.ts
  • src/main/git/command-runner/wsl-host-failure.ts
  • src/main/local-worktree-filesystem.ts
  • src/main/wsl/wsl-process-failure.ts

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

Walkthrough

WSL failure reporting now uses shared helpers to recognize host launch failures, clean stdout diagnostics, and format process errors. Several WSL callers use the shared formatter. Router tests cover host-failure output and a non-host exit code with empty stdout.

Priority: Low

Merge Risk: Minimal · up to f0793

The change improves WSL failure diagnostics without introducing an established runtime or integration risk.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surv… 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 describes the main change: improving WSL guest failure messages with diagnostic information.
Description check Passed The description covers the required sections, explains the user-visible change and mechanism, identifies the linked issue, documents testing and platform impact, and completes the relevant checklist i…
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 covers the required sections, explains the user-visible change and mechanism, identifies the linked issue, documents testing and platform impact, and completes the relevant checklist items. Manual testing is explicitly unchecked, but automated test coverage and reported module tests are provided.

Full details: Docstring Coverage

Explanation

Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 8 functions across 7 files.

Resolution

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

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • 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
nwparker merged commit 80c9278 into main Oct 27, 2026
78 of 80 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