fix: handle missing optional doctor binaries#36
Conversation
4595a3c to
b9f3ae4
Compare
mizchi
left a comment
There was a problem hiding this comment.
LGTM 主旨で、小さい指摘 2 つ。
nit: "not found" メッセージが 2 箇所に重複
新規の pre-check ブロック (L5405–) と既存の --version 失敗 fallback (L5440+ あたり) で、 optional の hint 文字列構築 + -- name: not found ... 出力が 行単位で同じ になってる。 小さい helper に纏めると差分が読みやすいかも:
fn doctor_print_not_found(check : DoctorCheck) -> Unit {
if check.required {
println("ERR " + check.name + ": not found (required)")
} else {
let hint = if check.env_override.length() > 0 {
" (optional, override with " + check.env_override + ")"
} else {
" (optional)"
}
println("-- " + check.name + ": not found" + hint)
}
}その上で pre-check と post---version-fail の両方からこれを呼ぶ。 helper 化と本 PR を 1 commit で混ぜず separate にしたいなら follow-up でも全然 OK。
nit: "not found" の意味が pre/post で違う
PR 後の挙動:
| シナリオ | 表示 | 実際 |
|---|---|---|
| bin 自体が PATH に無い | not found |
bin missing (正しい) |
bin はあるが --version が exit ≠ 0 |
not found |
bin exists but flag rejected |
後者は厳密には version probe failed (exit N) 的に書き分けた方が、 doctor を読んだ人がトラブルシュート時に迷わない (bin はあるのに not found って言われた!? を防げる)。 pre-existing なので blocker ではないけど、 今回触ったついでに分けても良い。
(informational) Windows portability
bin.contains("/") が absolute path 判定として使われてる。 C:\Tools\node.exe は \ なので fall through して which 呼び出しになる。 actrun が native Windows をターゲットにしてるなら where.exe も検討余地。 POSIX 専用なら無視で OK。
機能面は意図通り動くはずで、 これで node / docker / wasmtime 等が未インストールの環境でも doctor が abort せず動くようになるのは良い改善。
Address review feedback on mizchi#36: - Extract `doctor_optional_hint`, `doctor_print_not_found`, and `doctor_print_version_probe_failed` helpers so the "not found" / optional-hint formatting is no longer duplicated between the pre-check and the post `--version` failure branches. - Distinguish "binary not found" (pre-check) from "version probe failed (exit N)" (binary present but `--version` exits non-zero) so doctor output points operators at the right troubleshooting path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
レビューありがとうございます 🙏 2 点の nit に対応しました (2182eb3)。
Windows portability の informational 指摘は今回はスコープ外として見送り、必要があれば別 PR で対応します。 Validation
|
|
Claude にコメントさせたら自分が絶対に送らない文面でわろた |
* test: strip absolute repo root from expect snapshots The previous PR (#36) merge landed but 14 of 861 tests fail on CI because expect snapshots in executor_test.mbt / lib_test.mbt / compat_docs_test.mbt baked in the developer's local absolute path (`/Users/mz/ghq/github.com/mizchi/actrun/_build/...`). On the CI runner the path is `/home/runner/work/actrun/actrun/_build/...` or `/Users/runner/work/actrun/actrun/_build/...`, so the diff is verbatim: -"/Users/mz/ghq/github.com/mizchi/actrun/_build/test-workspaces/..." +"/home/runner/work/actrun/actrun/_build/test-workspaces/..." Fix: add `executor_test_strip_repo_root(s)` that replaces the `$PWD` prefix with the placeholder `<repo>`, and wrap every affected `debug_inspect`'s first arg with it (17 call sites across 3 files). Expect content updated to use `<repo>/_build/...`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * test: moon fmt pass on the path-strip wrap calls * ci: restore moon.mod.json + scope wasi-node-sidecar to CJS Two pre-existing failures uncovered alongside the path-strip fix in this PR — neither related to the test snapshots, but both need to go in for the branch to be CI-green: 1. nix-build (`flake.nix` / `package.nix` reference `./moon.mod.json`, which the MoonBit fmt-driven migration in 7405811 deleted in favor of `moon.mod`). moonbit-overlay's `buildMoonPackage.nix` still reads `moonModJson` via `builtins.readFile`, so it errors with `Path 'moon.mod.json' does not exist`. Fix: restore `moon.mod.json` (kept in sync with the current `moon.mod`). Dual-maintenance is the cheapest path until the overlay supports the new TOML format. Tracked there: https://github.com/moonbit-community/moonbit-overlay 2. compat-wasi-gha — sidecar `dist/index.js` uses CommonJS (`require("node:fs")`), but the root `package.json` has `"type": "module"`, so Node treats every `.js` under the repo as ESM and throws `ReferenceError: require is not defined in ES module scope`. Fix: a one-line local `package.json` in `.github/actions/wasi-node-sidecar/dist/` with `"type": "commonjs"`. Scopes the CJS interpretation to this prebuilt artifact without touching the root project's ESM policy. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ci: scope wasi-node-sidecar/dist to CommonJS Drop a local `package.json` with `"type": "commonjs"` next to the sidecar's `dist/index.js` so it's interpreted as CJS regardless of the root project's `"type": "module"`. Needed because the prebuilt sidecar uses `require("node:fs")`, and without this scope override compat-wasi-gha fails with `ReferenceError: require is not defined in ES module scope`. `-f` because `dist/` is gitignored but the sidecar's compiled artifacts are tracked the same way (existing index.js / index.wasm are also under the same exemption). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ci: nix flake update moonbit-overlay for newer moonc The pinned moonbit-overlay (50118f5 / 2026-03-31) shipped a moonc that rejects the type-inference-friendly `with fn output(self, logger)` syntax produced by the current `moon fmt`: Error: Missing type annotation for the parameter self. Error: Missing type annotation for the parameter logger. Local moonc accepts it; nix-build doesn't because the toolchain is older. Bumping the overlay to d7386ba (2026-05-26) pulls in a moonc that matches the local one and the build goes green. Verified locally with `nix build .#actrun` — succeeds end-to-end (only the standard uncommitted-changes warning, no errors). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
doctorbinary exists before invoking--version.not found (optional)instead of aborting onOSError.Validation
moon fmtmoon build --target native src/cmd/actrunmoon test --target nativemoon run src/cmd/actrun --target native -- doctor