{"record":{"id":"d9fc88d4c055c2f5","repo":"tinyhumansai/openhuman","slug":"command-failed-with-status-status","errorCode":null,"errorMessage":"command failed with status {status}","messagePattern":"command failed with status (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/openhuman/platform/service/common.rs","lineNumber":123,"sourceCode":"        .replace('\\'', \"&apos;\")\n}\n\n/// Suppress conhost allocation for Windows command spawns. Without this,\n/// every `schtasks /Query` polled by service status checks flashes a\n/// console — visible to users (#1475 follow-up to #731 + #1338).\n#[cfg(windows)]\nfn no_window(cmd: &mut Command) {\n    cmd.creation_flags(0x0800_0000); // CREATE_NO_WINDOW\n}\n\n#[cfg(not(windows))]\nfn no_window(_cmd: &mut Command) {}\n\npub(crate) fn run_checked(cmd: &mut Command) -> Result<()> {\n    no_window(cmd);\n    let status = cmd.status()?;\n    if !status.success() {\n        anyhow::bail!(\"command failed with status {status}\");\n    }\n    Ok(())\n}\n\npub(crate) fn run_capture(cmd: &mut Command) -> Result<String> {\n    no_window(cmd);\n    let output = cmd.output()?;\n    if !output.status.success() {\n        anyhow::bail!(\"command failed with status {}\", output.status);\n    }\n\n    Ok(String::from_utf8_lossy(&output.stdout).to_string())\n}\n\npub(crate) fn run_best_effort(cmd: &mut Command) {\n    no_window(cmd);\n    match cmd.stdout(Stdio::null()).stderr(Stdio::null()).status() {\n        Ok(status) => {","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/openhuman/platform/service/common.rs#L105-L141","documentation":"run_checked is the platform::service helper that runs service-management commands (launchctl/systemctl/sc style) and waits for exit; any non-zero exit status — including signal termination on Unix, which the ExitStatus Display shows — produces this bail. The child's stderr is inherited, so the human-readable reason is not in the error, only the status.","triggerScenarios":"Installing or starting the background service where the underlying command exits non-zero: systemctl on a system without systemd or with the unit masked; launchctl failing in restricted macOS contexts; sc failing on permission-denied; the daemon binary unresolvable is a different (earlier) error, so this specifically means the command ran and failed.","commonSituations":"Running service install inside a container without systemd; headless Linux sessions lacking a user systemd instance (no enable-linger); macOS LaunchAgents directory restricted; partially-completed prior installs leaving the manager in a bad state.","solutions":["Re-run the failing service command manually to see its stderr — e.g. `systemctl --user status openhuman-core` on Linux or `launchctl print gui/$(id -u)/<label>` on macOS.","Fix the environment: ensure a systemd user session exists on Linux (`loginctl enable-linger $USER` for headless), proper LaunchAgents permissions on macOS.","Verify the daemon executable resolves (OPENHUMAN_CORE_BIN override or sibling-binary lookup in common.rs) so the manager has something to launch.","Retry after the environment fix — a unit-not-yet-loaded race can surface the same status."],"exampleFix":"// before\nrun_checked(&mut cmd)?;\n\n// after — include the command line in the error so the failure is reproducible manually\nlet program = cmd.get_program().to_string_lossy().to_string();\nrun_checked(&mut cmd)\n    .map_err(|e| anyhow::anyhow!(\"{e}; while running `{program}` — rerun it manually to see stderr\"))?;","handlingStrategy":"try-catch","validationCode":"// Linux: is there actually a user systemd session to talk to?\nfn systemd_user_available() -> bool {\n    std::path::Path::new(\"/run/systemd/system\").exists()\n        && std::env::var(\"XDG_RUNTIME_DIR\").is_ok()\n}","typeGuard":null,"tryCatchPattern":"Catch the status error, log the program and args, then rerun the same command once with .output() to capture stderr for the user; distinguish 'environment lacks the service manager' (skip with a warning) from 'command genuinely failed' (surface the error).","preventionTips":["Verify the platform service manager exists before offering install in the UI.","Containers without systemd should not expose service install at all.","Keep the daemon binary resolvable (OPENHUMAN_CORE_BIN or sibling lookup).","Remember the bail hides child stderr — always reproduce manually when debugging."],"tags":["service","subprocess","exit-status","systemd","launchctl"],"backgroundTag":"subprocess-non-zero-exit","analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}