From 81125a233ba12f875c3aa59b08de825145c47546 Mon Sep 17 00:00:00 2001 From: 7418 <7418@openclaw.ai> Date: Sun, 8 Feb 2026 20:54:03 +0800 Subject: [PATCH] fix: auto-detect git-bash path on Windows (closes #23) Add findGitBash() to platform.ts that checks env var, common install paths, and derives path from `where git`. Used in claude-client.ts to set CLAUDE_CODE_GIT_BASH_PATH when not already configured. Co-Authored-By: Claude Opus 4.6 --- src/lib/claude-client.ts | 27 ++++++++++++++++++---- src/lib/platform.ts | 48 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 4 deletions(-) diff --git a/src/lib/claude-client.ts b/src/lib/claude-client.ts index bcf63ed..a081f42 100644 --- a/src/lib/claude-client.ts +++ b/src/lib/claude-client.ts @@ -18,7 +18,7 @@ import type { import type { ClaudeStreamOptions, SSEEvent, TokenUsage, MCPServerConfig, PermissionRequestEvent } from '@/types'; import { registerPendingPermission } from './permission-registry'; import { getSetting, getActiveProvider } from './db'; -import { findClaudeBinary, getExpandedPath } from './platform'; +import { findClaudeBinary, findGitBash, getExpandedPath } from './platform'; import os from 'os'; let cachedClaudePath: string | null | undefined; @@ -157,6 +157,14 @@ export function streamClaude(options: ClaudeStreamOptions): ReadableStream\cmd\git.exe or \bin\git.exe + const gitDir = path.dirname(path.dirname(gitExe)); + const bashPath = path.join(gitDir, 'bin', 'bash.exe'); + if (fs.existsSync(bashPath)) { + return bashPath; + } + } + } catch { + // where git failed or timed out + } + + return null; +}