{"record":{"id":"3e7bd9059726f5ab","repo":"zeroclaw-labs/zeroclaw","slug":"could-not-detect-init-system-supported-systemd","errorCode":null,"errorMessage":"Could not detect init system. Supported: systemd, OpenRC. Use --service-init to specify manually.","messagePattern":"Could not detect init system\\. Supported: systemd, OpenRC\\. Use --service-init to specify manually\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-runtime/src/service/mod.rs","lineNumber":585,"sourceCode":"/// Detect the active init system on Linux\n/// Checks for systemd and OpenRC in order, returning the first match.\n/// Returns an error if neither is detected.\n#[cfg(target_os = \"linux\")]\nfn detect_init_system() -> Result<InitSystem> {\n    // Check for systemd first (most common on modern Linux)\n    if linux_systemd_runtime_present() {\n        return Ok(InitSystem::Systemd);\n    }\n\n    // Check for OpenRC: requires /run/openrc AND openrc binary\n    if Path::new(\"/run/openrc\").exists() {\n        // Check for OpenRC binaries: /sbin/openrc-run or rc-service in PATH\n        if Path::new(\"/sbin/openrc-run\").exists() || which::which(\"rc-service\").is_ok() {\n            return Ok(InitSystem::Openrc);\n        }\n    }\n\n    bail!(\n        \"Could not detect init system. Supported: systemd, OpenRC. \\\n         Use --service-init to specify manually.\"\n    );\n}\n\npub(crate) fn linux_systemd_runtime_present() -> bool {\n    cfg!(target_os = \"linux\") && Path::new(\"/run/systemd/system\").exists()\n}\n\nfn windows_task_name() -> &'static str {\n    WINDOWS_TASK_NAME\n}\n\nfn linux_service_base(config: &Config) -> String {\n    let Some(dir_name) = config\n        .config_path\n        .parent()\n        .and_then(Path::file_name)","sourceCodeStart":567,"sourceCodeEnd":603,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-runtime/src/service/mod.rs#L567-L603","documentation":"On Linux, InitSystem::Auto.resolve() probes for systemd (runtime presence) and for OpenRC (/sbin/openrc-run on disk or rc-service in PATH). When neither is found the resolver gives up and asks the user to pass --service-init explicitly. This is an environment-detection failure, not a zeroclaw misconfiguration.","triggerScenarios":"Calling install/start/stop/status/logs/uninstall with InitSystem::Auto on Linux where systemd is not running (no /run/systemd/system markers) and no OpenRC binaries exist: minimal Docker images, distroless CI runners, chroots, WSL1, devcontainers.","commonSituations":"Running 'zeroclaw service install' inside Docker/CI where PID 1 is not systemd; stripped-down VMs without an init system; build agents that only run the binary for smoke tests.","solutions":["Pass the init system explicitly: zeroclaw service install --service-init systemd (or openrc)","If a real service is required, install/enable systemd or OpenRC in that environment first","In containers and CI, skip service management and run the daemon in the foreground"],"exampleFix":"# before\nzeroclaw service install\n# after\nzeroclaw service install --service-init systemd","handlingStrategy":"fallback","validationCode":"// replicate the runtime's detection before calling resolve()\nfn detect_init() -> Option<InitSystem> {\n    if std::path::Path::new(\"/run/systemd/system\").exists() {\n        return Some(InitSystem::Systemd);\n    }\n    if std::path::Path::new(\"/sbin/openrc-run\").exists() || which::which(\"rc-service\").is_ok() {\n        return Some(InitSystem::Openrc);\n    }\n    None\n}","typeGuard":null,"tryCatchPattern":"let init = match InitSystem::Auto.resolve() {\n    Ok(init) => init,\n    Err(_) => InitSystem::Systemd, // explicit fallback instead of failing\n};","preventionTips":["Decide the init system in deployment tooling and pass --service-init explicitly","Never attempt service management inside containers that lack an init system","Check /run/systemd/system existence when scripting conditional installs"],"tags":["linux","systemd","openrc","environment-detection","container"],"backgroundTag":"init-system-detection-failed","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}