[Bug]: Claude version probe drops CLI stderr, so a broken wrapper shows only "installed but failed to run"#22873
Area
apps/server
Steps to reproduce
- Install the Claude CLI wrapper so its postinstall never runs, leaving the placeholder stub it ships with:sh
1 npm i -g --ignore-scripts @anthropic-ai/claude-code@2.1.306 - Confirm the CLI fails and explains why:sh
1 $ claude --version; echo "exit=$?" 2 Error: claude native binary not installed. 3 4 Either postinstall did not run (--ignore-scripts, some pnpm configs) 5 or the platform-native optional dependency was not downloaded 6 (--omit=optional). 7 8 Run the postinstall manually (adjust path for local vs global install): 9 node node_modules/@anthropic-ai/claude-code/install.cjs 10 11 Or reinstall without --ignore-scripts / --omit=optional. 12 exit=1 - In T3 Code go to Settings → Providers and refresh the probe (the control next to "Checked just now", i.e.
server.refreshProviders).
Expected behavior
The provider card and/or the server log carry the CLI's own explanation, at least the first stderr line. The failing CLI already prints the exact fix command, and T3 has that text in hand.
Actual behavior
The card shows only:
Unavailable · Claude Agent CLI is installed but failed to run.
The only record is this warning, which keeps lengths and throws the text away (apps/server/src/provider/ClaudeProvider.ts:565-569):
| 1 | { |
| 2 | "name": "checkClaudeProviderStatus", |
| 3 | "events": [ |
| 4 | { |
| 5 | "name": "[\n \"Claude Agent CLI version probe exited with a non-zero status.\",\n {\n \"exitCode\": 1,\n \"stdoutLength\": 0,\n \"stderrLength\": 383\n }\n]", |
| 6 | "attributes": { "effect.logLevel": "WARN" } |
| 7 | } |
| 8 | ] |
| 9 | } |
Those 383 bytes of stderr were the message quoted in step 2. Since only the length is persisted, no UI surface can recover the cause afterwards. The user-facing message is hardcoded at :580.
Impact
Minor bug or occasional failure
Justification: once a wrapper install is broken, the provider is unusable and the report offers no path to recovery. Every wrapper breakage lands here identically — pnpm installs, --omit=optional, and Chocolatey-style installs as in #22810.
Version or commit
0.1.2-nightly.20261021.3473. Still present on main: apps/server/src/provider/ClaudeProvider.ts:562-582.
Environment
WSL2, Ubuntu 24.04.5 LTS (kernel 6.18.33.2-microsoft-standard-WSL2), Node v24.21.0 via fnm, @anthropic-ai/claude-code 2.1.306 (npm global). T3 host is the WSL distro (Settings header renders "on wsl"). Provider: Claude (claudeAgent); Codex and OpenCode were unaffected on the same host.
Logs or stack traces
| 1 | $ grep -h "version probe exited" ~/.t3/userdata/logs/server.trace.ndjson | tail -1 |
| 2 | {"type":"effect-span","name":"checkClaudeProviderStatus","durationMs":14.466428,"events":[{"name":"[\n \"Claude Agent CLI version probe exited with a non-zero status.\",\n {\n \"exitCode\": 1,\n \"stdoutLength\": 0,\n \"stderrLength\": 383\n }\n]","attributes":{"effect.logLevel":"WARN"}}]} |
Workaround
Run the wrapper's postinstall by hand, then refresh the provider probe:
| 1 | node "$(npm root -g)/@anthropic-ai/claude-code/install.cjs" |
The provider flips to Available once claude --version exits 0. This is restating step 2's own advice, which T3 discarded.
Suggested fix
| 1 | if (version.code !== 0) { |
| 2 | const detail = firstNonEmptyLine(version.stderr) || firstNonEmptyLine(version.stdout); |
| 3 | yield* Effect.logWarning("Claude Agent CLI version probe exited with a non-zero status.", { |
| 4 | exitCode: version.code, |
| 5 | stderr: truncate(version.stderr, 2000), // keep the text, not just its length |
| 6 | }); |
| 7 | // message: detail |
| 8 | // ? `Claude Agent CLI is installed but failed to run: ${detail}` |
| 9 | // : "Claude Agent CLI is installed but failed to run.", |
| 10 | } |
Same class of problem as #19571 (closed), which fixed stderr being dropped for turns. The availability probe was not covered by that fix.