# CherryStudio 启动 Claude Code 报错 “Bun failed to remap this bin“ 的终极修复指南
CherryStudio 启动 Claude Code 报错 “Bun failed to remap this bin” 的终极修复指南
问题现象
在 Windows 上使用 CherryStudio 调用 Claude Code 时,弹出命令行窗口报错:
error: could not create process
Bun failed to remap this bin to its proper location within node_modules.
This is an indication of a corrupted node_modules directory.
Please run 'bun install --force' in the project root and try
it again. If this message persists, please open an issue:
https://github.com/oven-sh/bun/issues
按照提示运行 bun install --force 无法解决问题。
根因分析
这个问题的根本原因有三层:
第一层:Bun 的 shim 机制
CherryStudio 在 C:\Users\<用户名>\.cherrystudio\bin\ 下创建了两个文件:
| 文件 | 大小 | 作用 |
|---|---|---|
claude.exe |
~13KB | Bun 编译的 shim 启动器 |
claude.bunx |
~118B | ASCII 文本,存储目标二进制路径 ..\node_modules\@anthropic-ai\claude-code\bin\claude.exe |
当 CherryStudio 调用 claude.exe 时,bun 的 shim 会读取 .bunx 文件找到真实的二进制路径,然后尝试"重新映射"(remap)到 node_modules 中。这个过程在 Windows 上容易失败,报出上述错误。
第二层:postinstall 脚本被阻止
@anthropic-ai/claude-code 这个 npm 包本身只包含一个 500 字节的占位符 bin/claude.exe。真正的原生二进制(约 235MB)存放在可选的平台依赖包中:
@anthropic-ai/claude-code-win32-x64/claude.exe ← 真正的 235MB 二进制
@anthropic-ai/claude-code/bin/claude.exe ← 500B 占位符
包的 postinstall 脚本(install.cjs)负责将原生二进制硬链接/复制到 bin/ 目录。但 Bun 默认会阻止 postinstall 脚本的执行(安全策略),导致 bin/claude.exe 永远是 500B 的占位符。
运行 bun pm untrusted 可以看到被阻止的脚本。
第三层:CherryStudio 调用的是 shim 而非真实二进制
CherryStudio 生成的启动批处理文件(位于 %TEMP%\CherryStudio\)直接调用了:
"C:\Users\<用户名>\.cherrystudio\bin\claude.exe"
这个路径下的 claude.exe 是 bun 的 shim(13KB),不是真正的二进制。它需要:
- 读取
.bunx找到目标路径 - 执行 bun 内部的 remap 逻辑
- 找到
node_modules中的真实二进制来启动
任何一步出问题都会报错。
解决方案
核心思路:跳过 bun 的 shim 层,让 CherryStudio 直接调用真实二进制。
第一步:下载/更新所需依赖
首先确保 ~/.cherrystudio/ 下有 package.json(如果 CherryStudio 没有自动创建):
cd $env:USERPROFILE\.cherrystudio
# 如果没有 package.json,手动创建
@'
{
"name": "cherrystudio-deps",
"version": "1.0.0",
"private": true,
"dependencies": {
"@anthropic-ai/claude-code": "2.1.153"
}
}
'@ | Out-File -Encoding UTF8 package.json
然后使用 CherryStudio 自带的 bun 安装依赖:
& "$env:USERPROFILE\.cherrystudio\bin\bun.exe" install --force
第二步:手动运行 postinstall 脚本
Bun 会阻止 postinstall,需要用 Node.js 手动执行:
node "$env:USERPROFILE\.cherrystudio\node_modules\@anthropic-ai\claude-code\install.cjs"
运行后确认 bin/claude.exe 大小变为 ~235MB:
ls "$env:USERPROFILE\.cherrystudio\node_modules\@anthropic-ai\claude-code\bin\claude.exe"
# 应该显示约 235,564,192 字节
第三步:用真实二进制替换 bun shim(关键步骤)
cd $env:USERPROFILE\.cherrystudio\bin
# 删除 bun 的 shim 文件
Remove-Item claude.exe, claude.bunx -Force
# 将真实二进制复制过来
Copy-Item "$env:USERPROFILE\.cherrystudio\node_modules\@anthropic-ai\claude-code-win32-x64\claude.exe" claude.exe
第四步:验证
& "$env:USERPROFILE\.cherrystudio\bin\claude.exe" --version
# 应输出: 2.1.153 (Claude Code)
重新启动 CherryStudio,问题解决。
注意事项
- CherryStudio 启动时可能会重新生成 bun shim 覆盖我们的修改。如果问题复现,重复第三步即可
- 每次 CherryStudio 或 Claude Code 版本更新后,可能也需要重复这些步骤
- 其他通过 CherryStudio 安装的 CLI 工具(如 Gemini CLI、opencode 等)如果遇到相同问题,解决方法类似
相关链接
- CherryStudio Issue #13346 - Code Tools unusable
- CherryStudio PR #14430 - 使用 cli-wrapper.cjs 替代原生二进制
- Bun Issue #16961 - Bun failed to remap
本文基于 CherryStudio v1.9.6 + Bun 1.3.1 + Claude Code 2.1.153,Windows 11 环境。
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐



所有评论(0)