Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,9 @@ async function runClaudeCode(
const child = spawn(claudePath, spawnArgs, {
stdio: "inherit",
env,
// On Windows the resolved launcher is a .cmd batch file; CreateProcess
// cannot run .cmd directly, it must go through cmd.exe (shell: true).
shell: process.platform === "win32",
});

child.on("error", (err) => {
Expand Down
13 changes: 12 additions & 1 deletion src/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@ export function getInstallationPath(id: string = DEFAULT_INSTALLATION_ID): strin
export function resolveClaudePath(): string {
try {
if (process.platform === "win32") {
return execSync("where claude", { encoding: "utf-8" }).trim().split(/\r?\n/)[0] ?? "claude";
const candidates = execSync("where claude", { encoding: "utf-8" })
.trim()
.split(/\r?\n/)
.filter(Boolean);
// `where` lists the extension-less sh shim first. CreateProcess (used by
// child_process.spawn without a shell) cannot execute it, so pick the
// .cmd/.exe/.bat launcher that Windows actually runs.
return (
candidates.find((p) => /\.(cmd|exe|bat)$/i.test(p)) ??
candidates[0] ??
"claude"
);
}
return execSync("which claude", { encoding: "utf-8" }).trim();
} catch {
Expand Down