Merge pull request #1460 from TeslA1402/patch-3.0.1
Some checks are pending
Docs / Build (push) Waiting to run
Docs / Deploy (push) Blocked by required conditions

bugfix: Handle spaces in Windows paths for cmd.exe spawn and apiKeyHelper
This commit is contained in:
musi 2026-06-26 21:09:59 +08:00 committed by GitHub
commit c1361581b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 10 deletions

View file

@ -58,7 +58,8 @@ async function main(): Promise<void> {
const launch = profileLaunchSpawnCommand(plan);
const child = spawn(launch.command, launch.args, {
env: childEnv,
stdio: "inherit"
stdio: "inherit",
windowsVerbatimArguments: !!launch.windowsVerbatimArguments
});
const code = await waitForChild(child);
process.exitCode = code;

View file

@ -13,6 +13,7 @@ export type ProfileLaunchPlan = {
export type ProfileLaunchSpawnCommand = {
args: string[];
command: string;
windowsVerbatimArguments?: boolean;
};
export function findProfileForOpen(config: Pick<AppConfig, "profile">, profileRef: string): ProfileConfig {
@ -98,15 +99,14 @@ export function profileLaunchSpawnCommand(plan: Pick<ProfileLaunchPlan, "args" |
command: plan.command
};
}
let cmdLine = `"${plan.command}"`;
if (plan.args && plan.args.length > 0) {
cmdLine += " " + plan.args.join(" ");
}
return {
args: [
"/d",
"/s",
"/v:off",
"/c",
windowsCommandScriptInvocation(plan.command, plan.args)
],
command: process.env.ComSpec || process.env.COMSPEC || "cmd.exe"
args: ["/d", "/v:off", "/c", cmdLine],
command: process.env.ComSpec || process.env.COMSPEC || "cmd.exe",
windowsVerbatimArguments: true
};
}

View file

@ -77,7 +77,7 @@ function applyClaudeCodeProfile(config: AppConfig, profile: ProfileConfig, token
const wrapperResult = writeClaudeCodeWrapper(config, profile);
const nextSettings = {
...settings,
apiKeyHelper: helperResult.file,
apiKeyHelper: process.platform === "win32" ? `"${helperResult.file}"` : helperResult.file,
env
};
const writeResult = writeFileWithBackup(settingsFile, `${JSON.stringify(nextSettings, null, 2)}\n`, { mode: privateFileMode });