fix(installer): bash PATH 自动修复 — Claude Code 核心工具依赖
Git for Windows 默认只把 cmd\ 加入 PATH (含 git.exe), 但 bash.exe 在 bin\ 目录, 导致 Claude Code 的 Bash 工具不可用. Phase 1 新增: 安装 Git 后自动检测 bash.exe 位置, 将 Git\bin 永久加入用户 PATH. 搜索 4 个常见安装路径. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d87b92319f
commit
6275ce55dc
@ -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 安装后再检查
|
# Claude Code 依赖 npm, 需要在 Node.js 安装后再检查
|
||||||
if (-not (Test-Cmd "claude") -and (Test-Cmd "npm")) {
|
if (-not (Test-Cmd "claude") -and (Test-Cmd "npm")) {
|
||||||
Log-Info "安装 Claude Code..."
|
Log-Info "安装 Claude Code..."
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user