{"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":714,"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":696,"sourceCodeEnd":732,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/system/services.rs#L696-L732","documentation":"Every systemctl invocation mise makes while applying bootstrap services goes through `run_systemctl`; when systemctl exits non-zero, mise surfaces the joined command and the captured stderr/stdout of the failure. This is a wrapper error: the underlying cause is whatever systemd reported for that specific subcommand (start, stop, enable, disable, mask, unmask, daemon-reload).","triggerScenarios":"`mise bootstrap apply` (or plan/apply via the elevated helper) runs e.g. `systemctl enable <unit>`, `systemctl restart <unit>`, or `systemctl daemon-reload` and the command exits non-zero — invalid unit file, unit not loaded, masked unit, polkit denial, or systemd not running as init.","commonSituations":"Unit file with syntax errors so daemon-reload or start fails; attempting to start a masked unit; running without root/polkit rights so enable/start is denied; systemd inactive in containers; unit referenced but its dependency (user, binary, ExecStart path) missing so start fails immediately.","solutions":["Re-run the exact `$ systemctl ...` line shown in the error output to reproduce the real failure","Check unit health: `systemctl status <unit>`, `journalctl -xeu <unit>`","Validate the unit file: `systemd-analyze verify /etc/systemd/system/<unit>` and fix reported directives","Ensure privileges: run apply as root or with sudo/polkit authorization","If systemd is not PID 1 (container), enable systemd or run outside such environments"],"exampleFix":"$ systemd-analyze verify /etc/systemd/system/myapp.service\n# before: ExecStart points to a missing binary -> start fails\nExecStart=/usr/local/bin/myapp-old\n# after\nExecStart=/usr/local/bin/myapp","handlingStrategy":"try-catch","validationCode":"command -v systemctl >/dev/null && [ -d /run/systemd/system ] && echo systemd-active || echo no-systemd","typeGuard":null,"tryCatchPattern":"if ! mise bootstrap apply 2>err.log; then grep -m1 'systemctl .* failed' err.log && systemctl status \"$unit\"; fi\n# surface the exact systemctl subcommand and re-run it manually for the real cause","preventionTips":["Run `systemd-analyze verify` on every unit file before letting mise manage it","Keep ExecStart paths absolute and confirm the binaries exist at apply time","Test bootstrap apply on a disposable machine before committing config changes"],"tags":["mise","bootstrap","systemd","systemctl","process-failed"],"backgroundTag":"systemctl-command-failed","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}