Claude Code 已内置 Rust 版 Bun

Simon Willison8 天前

Jarred Sumner 在介绍 Bun 用 Rust 重写时提到:Claude Code v2.1.181(6 月 17 日发布)及之后版本已经使用 Rust 移植版 Bun;在 Linux 上启动速度提升了 10%,但除此之外几乎没人注意到。

有开发者检查了本机 Claude Code 安装,尝试验证其中是否确实内置了 Rust 版 Bun。

检查内置 Bun 版本

可以先用 strings 查看 Claude 二进制文件中的 Bun 版本信息:

strings ~/.local/bin/claude | grep -m1 'Bun v1'

在该环境中输出为:

Bun v1.4.0 (macOS arm64)

当时 Bun 在 GitHub 上的最新正式版本是 5 月 12 日发布的 v1.3.14。因此,Claude Code 中出现 v1.4.0,支持了一个判断:它可能打包了尚未正式发布的 Bun 预览版本。

后续更新显示,Rust 版本已经以 Bun canary 形式发布,可通过以下命令安装:

bun upgrade --canary

检查 Rust 源文件痕迹

另一个检查方式是搜索二进制文件中出现的 Rust 源文件路径:

strings ~/.local/bin/claude | grep -Eo 'src/[[:alnum:]_./-]+\.rs'

该命令输出了 563 个文件名,其中开头包括:

src/runtime/bake/dev_server/mod.rs
src/runtime/bake/production.rs
src/bundler/bundle_v2.rs

这些结果表明,Claude Code 中确实包含大量 Rust 源文件路径痕迹,与“使用 Rust 版 Bun”的说法相符。

通过预加载脚本确认 Bun.version

还有一种更直接的方式:创建一个临时 TypeScript 文件,在 Claude 启动时通过 BUN_OPTIONS 预加载,并输出内置 Bun 版本。

cat > /tmp/bun-version.ts <<'EOF'
console.log("embedded bun:", Bun.version);
process.exit(0);
EOF

BUN_OPTIONS="--preload=/tmp/bun-version.ts" claude --version

该方法在测试环境中的输出为:

1.4.0

此外,Bun 的 package.json 曾在 5 月 17 日提交中将版本更新为 1.4.0。该版本号此后没有变化,但截至测试时,除 canary 外尚未进入正式标记版本。

整体来看,Claude Code v2.1.181 及之后版本内置 Rust 版 Bun 的说法,有二进制字符串、Rust 文件路径和运行时版本输出等多项迹象支持。对于用户而言,这一变更几乎无感;对于运行时实现而言,这说明 Rust 版 Bun 已经进入真实生产环境。

评论

请登录后发表观点

暂无数据