From b9f3ae4582e2d5eda4849e5adc4572bd2c86b189 Mon Sep 17 00:00:00 2001 From: Ubugeeei Date: Tue, 26 May 2026 00:51:12 +0900 Subject: [PATCH 1/2] fix: handle missing optional doctor binaries --- src/cmd/actrun/main.mbt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/cmd/actrun/main.mbt b/src/cmd/actrun/main.mbt index 91ac867..8aa475c 100644 --- a/src/cmd/actrun/main.mbt +++ b/src/cmd/actrun/main.mbt @@ -5351,6 +5351,16 @@ fn doctor_wasm_runner_bin() -> String { } } +///| +async fn doctor_bin_exists(bin : String) -> Bool { + if bin.contains("/") { + @xfs.path_exists(bin) + } else { + let (code, _, _) = run_command("which", [bin], cwd=".") + code == 0 + } +} + ///| async fn handle_doctor_command() -> Int { let checks : Array[DoctorCheck] = [ @@ -5392,6 +5402,20 @@ async fn handle_doctor_command() -> Int { } else { check.bin } + if !doctor_bin_exists(bin) { + if check.required { + println("ERR " + check.name + ": not found (required)") + has_error = true + } else { + let hint = if check.env_override.length() > 0 { + " (optional, override with " + check.env_override + ")" + } else { + " (optional)" + } + println("-- " + check.name + ": not found" + hint) + } + continue + } let (code, stdout, _) = run_command(bin, ["--version"], cwd=".") if code == 0 { let version = stdout.trim(chars=" \t\r\n").to_string() From 2182eb33509cd6cc814f49908aa41121c7b19832 Mon Sep 17 00:00:00 2001 From: ubugeeei Date: Tue, 26 May 2026 13:47:15 +0900 Subject: [PATCH 2/2] refactor: extract doctor helpers and clarify version probe failures Address review feedback on #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) --- src/cmd/actrun/main.mbt | 51 ++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/src/cmd/actrun/main.mbt b/src/cmd/actrun/main.mbt index 8aa475c..cadc2af 100644 --- a/src/cmd/actrun/main.mbt +++ b/src/cmd/actrun/main.mbt @@ -5361,6 +5361,37 @@ async fn doctor_bin_exists(bin : String) -> Bool { } } +///| +fn doctor_optional_hint(check : DoctorCheck) -> String { + if check.env_override.length() > 0 { + " (optional, override with " + check.env_override + ")" + } else { + " (optional)" + } +} + +///| +fn doctor_print_not_found(check : DoctorCheck) -> Unit { + if check.required { + println("ERR " + check.name + ": not found (required)") + } else { + println("-- " + check.name + ": not found" + doctor_optional_hint(check)) + } +} + +///| +fn doctor_print_version_probe_failed( + check : DoctorCheck, + exit_code : Int, +) -> Unit { + let probe = "version probe failed (exit " + exit_code.to_string() + ")" + if check.required { + println("ERR " + check.name + ": " + probe + " (required)") + } else { + println("-- " + check.name + ": " + probe + doctor_optional_hint(check)) + } +} + ///| async fn handle_doctor_command() -> Int { let checks : Array[DoctorCheck] = [ @@ -5403,16 +5434,9 @@ async fn handle_doctor_command() -> Int { check.bin } if !doctor_bin_exists(bin) { + doctor_print_not_found(check) if check.required { - println("ERR " + check.name + ": not found (required)") has_error = true - } else { - let hint = if check.env_override.length() > 0 { - " (optional, override with " + check.env_override + ")" - } else { - " (optional)" - } - println("-- " + check.name + ": not found" + hint) } continue } @@ -5424,16 +5448,11 @@ async fn handle_doctor_command() -> Int { None => version } println("ok " + check.name + ": " + short_version) - } else if check.required { - println("ERR " + check.name + ": not found (required)") - has_error = true } else { - let hint = if check.env_override.length() > 0 { - " (optional, override with " + check.env_override + ")" - } else { - " (optional)" + doctor_print_version_probe_failed(check, code) + if check.required { + has_error = true } - println("-- " + check.name + ": not found" + hint) } } // Check nix environment