{"record":{"id":"bb75f40920f6f3a1","repo":"zeroclaw-labs/zeroclaw","slug":"the-launchd-daemon-runner-is-only-supported-on-mac","errorCode":null,"errorMessage":"the launchd daemon runner is only supported on macOS","messagePattern":"the launchd daemon runner is only supported on macOS","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-runtime/src/service/mod.rs","lineNumber":336,"sourceCode":"{\n    let mut buffer = vec![0; 16 * 1024];\n    loop {\n        match pipe.read(&mut buffer).await {\n            Ok(0) => break,\n            Ok(read) => sink.push(buffer[..read].to_vec()),\n            Err(error) => {\n                sink.push(format!(\"launchd log pipe read failed: {error}\\n\").into_bytes());\n                break;\n            }\n        }\n    }\n}\n\npub async fn run_launchd_daemon(config_dir: &Path) -> Result<()> {\n    #[cfg(not(target_os = \"macos\"))]\n    {\n        let _ = config_dir;\n        bail!(\"the launchd daemon runner is only supported on macOS\")\n    }\n\n    #[cfg(target_os = \"macos\")]\n    {\n        let paths = launchd_capture_paths(config_dir);\n        run_with_launchd_capture(paths, || {\n            let executable = std::env::current_exe()\n                .context(\"Failed to resolve the launchd daemon executable\")?;\n            let mut command = TokioCommand::new(executable);\n            command.arg(\"--config-dir\").arg(config_dir).arg(\"daemon\");\n            Ok(command)\n        })\n        .await\n    }\n}\n\n#[cfg(any(target_os = \"macos\", test))]\nasync fn run_with_launchd_capture<F>(paths: LaunchdCapturePaths, make_command: F) -> Result<()>","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-runtime/src/service/mod.rs#L318-L354","documentation":"run_launchd_daemon is compiled as a stub on non-macOS targets that always bails (service/mod.rs:333-338). The launchd daemon runner captures launchd-managed stdout/stderr paths, so calling it on Linux or Windows can never succeed.","triggerScenarios":"Invoking the launchd daemon entry point on a Linux or Windows build — e.g. a service dispatcher keyed by config instead of OS, or a Linux CI host running macOS-targeted service commands.","commonSituations":"A macos-style service config deployed to a Linux box; cross-platform binary with a single hardcoded runner; CI matrix running the launchd path on the wrong OS job.","solutions":["Gate the call: invoke run_launchd_daemon only when std::env::consts::OS == \"macos\" (or via #[cfg(target_os = \"macos\")])","On Linux use the OpenRC runner (run_openrc_log_writer) or the platform-appropriate service path","Derive the runner choice from the detected OS in your dispatcher"],"exampleFix":"// before\nrun_launchd_daemon(config_dir).await?;\n\n// after\n#[cfg(target_os = \"macos\")]\nrun_launchd_daemon(config_dir).await?;\n#[cfg(not(target_os = \"macos\"))]\nanyhow::bail!(\"launchd runner requires macOS; this build targets {}\", std::env::consts::OS);","handlingStrategy":"validation","validationCode":"fn is_macos() -> bool {\n    std::env::consts::OS == \"macos\"\n}\n\nif is_macos() {\n    run_launchd_daemon(config_dir).await?;\n} else {\n    tracing::warn!(os = std::env::consts::OS, \"skipping launchd daemon: macOS only\");\n}","typeGuard":"fn supports_launchd() -> bool { cfg!(target_os = \"macos\") }","tryCatchPattern":"If the call still fails, treat 'only supported on macOS' as a dispatcher bug: log the detected OS and route to the OpenRC or platform runner; never retry the launchd path on a non-macOS host.","preventionTips":["Select daemon runners from runtime OS detection","Keep per-OS CI coverage for service commands","Refuse to install macOS service definitions on non-macOS hosts"],"tags":["service","launchd","platform-support","macos","rust"],"backgroundTag":"unsupported-platform","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}