From 2bd680361af1f3d62729eca9093d471e11aafb4c Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Sun, 30 Nov 2025 17:58:37 +0800 Subject: [PATCH] fix: set CLAUDE_CONFIG_DIR to avoid path encoding issues on Windows with non-ASCII usernames (#11550) * Initial plan * fix: set CLAUDE_CONFIG_DIR to avoid path encoding issues on Windows with non-ASCII usernames Co-authored-by: DeJeune <67425183+DeJeune@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: DeJeune <67425183+DeJeune@users.noreply.github.com> --- src/main/services/agents/services/claudecode/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/services/agents/services/claudecode/index.ts b/src/main/services/agents/services/claudecode/index.ts index 53b318c5b2..e5cefadd68 100644 --- a/src/main/services/agents/services/claudecode/index.ts +++ b/src/main/services/agents/services/claudecode/index.ts @@ -1,6 +1,7 @@ // src/main/services/agents/services/claudecode/index.ts import { EventEmitter } from 'node:events' import { createRequire } from 'node:module' +import path from 'node:path' import type { CanUseTool, @@ -121,7 +122,11 @@ class ClaudeCodeService implements AgentServiceInterface { // TODO: support set small model in UI ANTHROPIC_DEFAULT_HAIKU_MODEL: modelInfo.modelId, ELECTRON_RUN_AS_NODE: '1', - ELECTRON_NO_ATTACH_CONSOLE: '1' + ELECTRON_NO_ATTACH_CONSOLE: '1', + // Set CLAUDE_CONFIG_DIR to app's userData directory to avoid path encoding issues + // on Windows when the username contains non-ASCII characters (e.g., Chinese characters) + // This prevents the SDK from using the user's home directory which may have encoding problems + CLAUDE_CONFIG_DIR: path.join(app.getPath('userData'), '.claude') } const errorChunks: string[] = []