Repository navigation
chore(build): 本地 bun 版本与 packageManager 不一致时告警 - #2053
Merged
Merged
Conversation
bun 不校验 package.json 的 packageManager 字段,本地版本漂移不会报错, 只会让编译产物、bun.lock 重写、bun test 的行为悄悄与 CI 不一致。 - 新增 scripts/check-bun-version.mjs:比对本地 bun 与 packageManager, 不一致时往 stderr 告警并给出安装指定版本的命令;永不让调用方失败 - bun run build 开头执行;scripts/build-bun-binary.mjs 入口也检查 (CI 与文档直接调用它,不经过 bun run build:bun) - CLAUDE.md 同步说明唯一来源与对齐方式
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
October 20, 2026 07:49
自执判定里的 realpathSync(argv[1]) 在 try/catch 外,argv[1] 指向已不存在的 路径时会抛 ENOENT 并以非 0 退出,与脚本「永不让调用方失败」的契约不符。 把守卫整体包进 try/catch,并加回归测试(node 与 bun 双运行时)。 Co-Authored-By: Claude Code <[email protected]>
裸 spawnSync(process.execPath, ['-e', src]) 在 Node 下缺 --input-type=module (老版本 Node 对 -e 的 ESM 语法报 SyntaxError),也不符合仓库测试 spawn 必须走 test/helpers/ts-runner.ts 的约定;改用 spawnSyncTsEval,由 helper 按运行时 拼出 node --input-type=module -e / bun -e。 Co-Authored-By: Claude Code <[email protected]>
|
🚀 Released in v3.48.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改了什么
scripts/check-bun-version.mjs:比对本地 bun 版本与package.json的packageManager(当前[email protected]),不一致时往 stderr 打告警,并给出安装指定版本的命令。只告警,不拦截:脚本内部任何错误都会被吞掉,退出码恒为 0。bun run build开头执行这个检查。scripts/build-bun-binary.mjs在入口处 import 并调用检查。CI 和文档都是直接执行bun scripts/build-bun-binary.mjs,不经过bun run build:bun,只改 npm script 会漏掉这些调用。packageManager,以及漂移时怎么对齐。告警示例:
为什么
bun 不校验
packageManager字段,engines也只声明了 node,本地 bun 版本漂移时不会有任何报错。但编译产物(bun build --compile)、bun.lock重写、bun test的语义都随 bun 版本变化,出问题时很难想到是工具链版本不一致。此前 CLAUDE.md 只写了「排查前核对bun --version」,没有任何机制真正去比对。开发机就曾停在比 CI 低一个 patch 的版本上,一直没人发现。设计取舍:
packageManager,不另加.bun-version:test/release-darwin-codesign-gate.test.ts已经保证各 workflow 的bun-version/npm i -g bun@…与它一致,再加一个版本文件只会多一份可能漂移的副本。preinstall:根包的preinstall会在终端用户npm i -g botmux时执行,在那里告警 bun 版本只会打扰用户。bun upgrade:bun upgrade只能升到最新版,可能越过 pin;官方脚本可以指定版本。它是解压到同目录后mv替换(换 inode),fleet 里正在运行的 bun 进程不受影响;并且 bun 已在 PATH 上时,它会在修改 shell rc 之前退出。影响面
src/、不改dist运行时产物,不影响 daemon、worker、任何 CLI 适配器、后端或会话类型。process.versions.bun,用 node 跑时才回退到bun --version。测试验证
process.exit(1)」,测试warns on drift but still exits 0变红;恢复后转绿。build-bun-binary.mjs,先打出告警,再按原有逻辑因缺少 dist 失败,没有生成产物。