diff --git a/auto-setup.ps1 b/auto-setup.ps1 index d15928d..d581602 100644 --- a/auto-setup.ps1 +++ b/auto-setup.ps1 @@ -604,6 +604,31 @@ foreach ($dep in $deps) { } } +# ── bash PATH 自动修复 (Claude Code 的核心工具依赖 bash) ── +# Git 默认只把 cmd\ 加 PATH (有 git.exe), 但 bash.exe 在 bin\ 目录 +if ((Test-Cmd "git") -and -not (Test-Cmd "bash")) { + $gitBinPaths = @( + "$env:ProgramFiles\Git\bin", + "${env:ProgramFiles(x86)}\Git\bin", + "D:\Git\bin", + "$env:LOCALAPPDATA\Programs\Git\bin" + ) + $gitBin = $gitBinPaths | Where-Object { Test-Path (Join-Path $_ "bash.exe") } | Select-Object -First 1 + if ($gitBin) { + # 加入用户 PATH (永久) + $userPath = [System.Environment]::GetEnvironmentVariable("Path", "User") + if ($userPath -notmatch [regex]::Escape($gitBin)) { + [System.Environment]::SetEnvironmentVariable("Path", "$userPath;$gitBin", "User") + $env:Path += ";$gitBin" + Log-OK "bash 已加入 PATH: $gitBin" + } + } else { + Log-Warn "Git 已安装但找不到 bash.exe (Claude Code Bash 工具可能不可用)" + } +} elseif (Test-Cmd "bash") { + Log-OK "bash 已就绪" +} + # Claude Code 依赖 npm, 需要在 Node.js 安装后再检查 if (-not (Test-Cmd "claude") -and (Test-Cmd "npm")) { Log-Info "安装 Claude Code..."