Repository navigation
fix(claude-accounts): quote resolved claude path for Windows shell spawn - #10237
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between c7c80d4964075ffb4b5c92b6d712d7835d44be3b and a656763. 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughWindows Claude command execution now builds explicit 🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
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. Comment |
runClaudeCommand spawns the resolved claude command with shell:true on Windows, but spawn concatenates the command into the cmd.exe line without quoting. When the CLI resolves to a path containing spaces (e.g. C:\Users\First Last\AppData\Roaming\npm\claude.cmd), cmd.exe splits at the first space and account add fails with: 'C:\Users\First' is not recognized as an internal or external command Quote the command the same way claude-pty.ts and quoteWindowsCmdArg already do for other Windows spawns. Co-Authored-By: Claude Fable 5 <[email protected]>
OrcaWin
left a comment
There was a problem hiding this comment.
Thanks for the precise report and Windows reproduction. The diagnosis is correct, and quoting the resolved command does fix the common profile-path-with-spaces case.
Requesting changes because the current shell:true boundary still lets cmd.exe interpret valid path and argument characters. On a physical Windows host with Node 24 and a real .cmd shim:
- The reported spaced and Unicode path passed with this PR.
- A valid path containing %ORCA_PATH_TRAP% was environment-expanded and no longer addressed the intended command.
- Empty and spaced arguments were lost or split.
- &, |, <, >, ^, and % arguments were interpreted by cmd.exe; the > case physically redirected output and created a file.
- Node emitted DEP0190 because arguments passed with shell:true are concatenated without escaping.
- Error propagation and taskkill tree cancellation passed for the ordinary spaced-path case.
Please move ownership of the complete Windows command line into Orca: invoke ComSpec explicitly with /d /v:off /s /c, use shell:false plus windowsVerbatimArguments:true, quote every command/argument token, and protect percent expansion outside quoted spans. Keep the WSL branch ahead of native Claude resolution so WSL remains independent, and wait for taskkill completion before cleaning up the managed auth directory.
The regression test should supplement spawn mocks with a real Windows .cmd fixture under a temporary path containing spaces, Unicode, &, ^, parentheses, %, and !. It should capture exact argv/env, cover empty/spaced and cmd-metacharacter arguments, stderr/exit status, and verify taskkill removes the shell/child/grandchild tree.
This is a good issue diagnosis and a useful contribution; the requested change is specifically about making the Node-to-cmd.exe authority boundary safe enough to merge.
Addressed by maintainer follow-up commit c7c80d496; awaiting GitHub CI.
c7c80d4 to
a656763
Compare
This reverts commit 8f40ddf (#10179). Rebased on current main. The revert applied cleanly across the vast majority of the 1,626-file PR; the remaining work was preserving PRs that had been built on top of #10179 after it merged. All are preserved: - #9990 perf(terminal): cold-restore replay - #10213 fix(codex): TUI settings promotion - #10135 fix(mobile): images in native chat - #9387 fix(status-bar): Resource Manager badge + concurrent listSessions - #9853 fix(app): bound wake/quit paths (phone-session-ended freeze) - #10237 fix(claude-accounts): quote claude path for Windows (kept shell:false) Because those PRs were written against helper modules/APIs that #10179 introduced, the minimal, typecheck-verified closure they depend on is kept so the tree builds and every later-PR test passes: - bounded file/JSON readers used by #10213/#9990 (agent-state-file-reader, node-bounded-file-reader, json-text-structure-limit, terminal-history limits) - claimed-agent-pty-owner cap API + pty:listSessions admission (#9990/#9387) - the mobile-E2EE outbound-memory-budget subsystem #9853 builds on (e2ee-channel, mobile-e2ee-*, ws-outbound-backpressure-queue, remote-runtime-request-frames/-memory-limits, map-with-concurrency, e2ee-crypto) Everything else #10179 added (~555 files) is deleted; every file it modified elsewhere is restored to its pre-#10179 state. Verified: root typecheck (node+cli+web), mobile typecheck, full root test suite, full mobile test suite, oxlint, localization catalog + coverage, reliability gates, max-lines ratchet, and the CLI emit build all pass. Two checks fail only locally and fail identically on clean origin/main (this clone's git-tag namespace for verify:skill-bundle-manifest; an inherited GIT_CONFIG_* env for one relay test) — both pass on a clean CI environment. Co-authored-by: Orca <[email protected]>
…awn (stablyai#10237) * fix(claude-accounts): quote resolved claude path for Windows shell spawn runClaudeCommand spawns the resolved claude command with shell:true on Windows, but spawn concatenates the command into the cmd.exe line without quoting. When the CLI resolves to a path containing spaces (e.g. C:\Users\First Last\AppData\Roaming\npm\claude.cmd), cmd.exe splits at the first space and account add fails with: 'C:\Users\First' is not recognized as an internal or external command Quote the command the same way claude-pty.ts and quoteWindowsCmdArg already do for other Windows spawns. Co-Authored-By: Claude Fable 5 <[email protected]> * fix(claude-accounts): own Windows cmd invocation --------- Co-authored-by: Claude Fable 5 <[email protected]> Co-authored-by: OrcaWin <[email protected]>
Fixes #10236
Problem
runClaudeCommandspawns the resolved claude CLI withshell: trueon Windows, butspawnconcatenates the command into thecmd.exeline without quoting. When the CLI resolves to a path with spaces (anyC:\Users\First Last\...profile, npm install), cmd.exe splits at the first space and every Claude account operation (add, status) fails with:Fix
Quote the resolved command when it will pass through the Windows shell, mirroring what the codebase already does for the same situation in
claude-pty.ts(cmd.exe /c "<quoted path>", "ensure the command path is properly quoted if it contains spaces") andquoteWindowsCmdArginai-vault-types.ts. Non-Windows spawn (shell: false) is unchanged; the WSL branch was never affected.Tests
win32, a resolved path containing spaces is passed tospawnquoted, withshell: true.uses taskkill to cancel the Windows Claude login process treeexpectation to the quoted command ('"claude"') — the intended behavior change.resolveClaudeCommandmock to avi.hoisted+vi.fnso a single test can override the resolved path withoutdoUnmockwiping the hoisted mock for later tests.vitest run src/main/claude-accounts/service.test.ts: 26/26 pass (on a Windows host with a space in the profile path — previously 2 of these tests could only pass on hosts without one).oxlintandtsc --noEmit -p config/tsconfig.node.jsonclean on the touched files.Verified end-to-end on Windows 11 (profile
C:\Users\Ji Hoon, claude 2.1.218 under%APPDATA%\npm): reproducing the exact resolve +shell: truespawn fails unquoted and succeeds quoted.🤖 Generated with Claude Code