fix(v3.2.0): 移除 Bun crash 降级逻辑 (根因: 安装后 claude 被降到 v2.0.1)

- 删除 claude --version 自检 → 自动降级到 2.0.1 的逻辑
- Claude Code 2.1.x+ 已不使用 Bun, 降级完全不必要
- 此逻辑导致对方机器 claude 被降到 v2.0.1 (远古版本)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
bookworm 2026-04-27 21:56:56 +08:00
parent 697b58ef15
commit 47079cb8b1
2 changed files with 1 additions and 24 deletions

Binary file not shown.

View File

@ -2750,30 +2750,7 @@ if ($allOK -and $env:ANTHROPIC_API_KEY) {
$splash.Close() $splash.Close()
$splash.Dispose() $splash.Dispose()
# v3.0.1: Bun crash 预检 (Claude Code 2.1.x 内置 Bun, 部分 Win10/CPU 触发 Illegal instruction) # v3.2.0: Bun crash 降级逻辑已移除 (Claude Code 2.1.x+ 不再使用 Bun, 无需降级到 2.0.1)
# 先静默跑 `claude --version` 测试 3 秒, 若 crash 自动降到 2.0.1 纯 Node 版
$claudeVerOK = $false
try {
# 加超时: Bun crash 可能导致 claude --version 挂起不退出, -Wait 会卡死
$proc = Start-Process -FilePath "claude" -ArgumentList "--version" -NoNewWindow -PassThru -RedirectStandardOutput "$env:TEMP\bw-claude-ver.txt" -RedirectStandardError "$env:TEMP\bw-claude-err.txt" -WindowStyle Hidden
$exited = $proc.WaitForExit(8000) # 8 秒硬超时
if (-not $exited) {
try { $proc.Kill() } catch {}
Log-Warn "Claude Code --version 超过 8 秒无响应 (疑似 Bun 卡死)"
} elseif ($proc.ExitCode -eq 0) {
$out = Get-Content "$env:TEMP\bw-claude-ver.txt" -Raw -ErrorAction SilentlyContinue
if ($out -match "\d+\.\d+\.\d+") { $claudeVerOK = $true; Log-OK "Claude Code 自检: $($Matches[0])" }
} else {
Log-Warn "Claude Code 自检退出码非 0: $($proc.ExitCode) (可能 Bun Illegal instruction)"
}
Remove-Item "$env:TEMP\bw-claude-ver.txt","$env:TEMP\bw-claude-err.txt" -EA SilentlyContinue
} catch {}
if (-not $claudeVerOK) {
Log-Warn "Claude Code 2.1.x Bun 自检失败 (可能 Illegal instruction), 自动降级到 2.0.1 纯 Node 版..."
Run-CmdWithUI "npm" @("uninstall", "-g", "@anthropic-ai/claude-code") "卸载现版" 120000 | Out-Null
$r = Run-CmdWithUI "npm" @("install", "-g", "@anthropic-ai/claude-code@2.0.1") "安装 2.0.1 纯 Node 版" 180000
if ($r.OK) { Log-OK "Claude Code 降级到 2.0.1 (Bun crash 规避)" } else { Log-Warn "降级失败, 仍尝试原版启动" }
}
# v3.0.1: 启动 Bookworm — 彻底绕开 .bat + claude.cmd shim # v3.0.1: 启动 Bookworm — 彻底绕开 .bat + claude.cmd shim
# 直接调 claude.ps1 (npm 全局装时生成, PS 原生, 不会经 cmd.exe) # 直接调 claude.ps1 (npm 全局装时生成, PS 原生, 不会经 cmd.exe)