{"record":{"id":"a85bd77d6de33fd5","repo":"jdx/mise","slug":"systemctl-failed","errorCode":null,"errorMessage":"systemctl {} failed: {}","messagePattern":"systemctl (.+?) failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/services.rs","lineNumber":573,"sourceCode":"        active_state: properties\n            .get(\"ActiveState\")\n            .copied()\n            .unwrap_or(\"unknown\")\n            .to_string(),\n        unit_file_state: properties\n            .get(\"UnitFileState\")\n            .copied()\n            .unwrap_or(\"unknown\")\n            .to_string(),\n        need_daemon_reload: properties.get(\"NeedDaemonReload\") == Some(&\"yes\"),\n    }\n}\n\nfn run_systemctl(systemctl: &std::path::Path, args: &[String]) -> Result<()> {\n    info!(\"$ {} {}\", systemctl.display(), shell_words::join(args));\n    let output = systemctl_output(systemctl, args)?;\n    if !output.status.success() {\n        bail!(\n            \"systemctl {} failed: {}\",\n            shell_words::join(args),\n            output_error(&output)\n        );\n    }\n    Ok(())\n}\n\nfn systemctl_output(systemctl: &std::path::Path, args: &[String]) -> Result<Output> {\n    Ok(Command::new(systemctl)\n        .args(args)\n        .env(\"LC_ALL\", \"C\")\n        .env(\"SYSTEMD_PAGER\", \"\")\n        .output()?)\n}\n\nfn output_error(output: &Output) -> String {\n    let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string();","sourceCodeStart":555,"sourceCodeEnd":591,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/services.rs#L555-L591","documentation":"A `systemctl` invocation spawned by mise (enable, start, daemon-reload, etc.) exited with a non-zero status. mise surfaces the full argument list plus systemctl's own stderr/stdout (via `output_error`) so the underlying systemd reason is visible.","triggerScenarios":"Any privileged bootstrap-service plan step routed through `run_systemctl` where systemctl returns failure — e.g. enabling a non-existent unit, daemon-reload without a running systemd, or starting a unit with a broken unit file.","commonSituations":"Typo in a service name in mise.toml; unit file has a syntax error; systemd not running (containers, WSL1 without systemd); insufficient privileges reaching systemctl despite elevation.","solutions":["Read the captured systemctl stderr in the error message for the systemd-level cause","Run the same `systemctl <args>` command by hand to reproduce and inspect","Validate the unit file with `systemd-analyze verify <unit>`","Confirm systemd is PID 1 and reachable (`systemctl is-system-running`)"],"exampleFix":"// before: invalid unit dependency\n[Unit]\nAfter=nonexistent.target\n// after\n[Unit]\nAfter=network.target","handlingStrategy":"try-catch","validationCode":"systemd-analyze verify /etc/systemd/system/<unit> && systemctl is-system-running","typeGuard":null,"tryCatchPattern":"if let Err(e) = apply_plan() { if e.contains(\"systemctl\") { log_systemctl_hint(&e); } }","preventionTips":["Validate unit files with systemd-analyze before applying","Confirm systemd runs as PID 1 in your environment","Test systemctl commands manually first"],"tags":["systemd","command-failed","bootstrap-service"],"backgroundTag":"git-command-failed","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}