Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 51 additions & 8 deletions src/cmd/actrun/main.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -5351,6 +5351,47 @@ 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
}
}

///|
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] = [
Expand Down Expand Up @@ -5392,6 +5433,13 @@ async fn handle_doctor_command() -> Int {
} else {
check.bin
}
if !doctor_bin_exists(bin) {
doctor_print_not_found(check)
if check.required {
has_error = true
}
continue
}
let (code, stdout, _) = run_command(bin, ["--version"], cwd=".")
if code == 0 {
let version = stdout.trim(chars=" \t\r\n").to_string()
Expand All @@ -5400,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
Expand Down
Loading