{"record":{"id":"f82ec259133717b2","repo":"tinyhumansai/openhuman","slug":"service-management-is-supported-on-macos-linux-a","errorCode":null,"errorMessage":"Service management is supported on macOS, Linux, and Windows only","messagePattern":"Service management is supported on macOS, Linux, and Windows only","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/openhuman/platform/service/core.rs","lineNumber":49,"sourceCode":"    }\n\n    #[cfg(target_os = \"macos\")]\n    {\n        macos::install(config)?;\n        status(config)\n    }\n    #[cfg(target_os = \"linux\")]\n    {\n        linux::install(config)?;\n        status(config)\n    }\n    #[cfg(windows)]\n    {\n        windows::install(config)?;\n        status(config)\n    }\n    #[cfg(not(any(target_os = \"macos\", target_os = \"linux\", windows)))]\n    anyhow::bail!(\"Service management is supported on macOS, Linux, and Windows only\")\n}\n\npub fn start(config: &Config) -> Result<ServiceStatus> {\n    if super::mock::is_enabled() {\n        return super::mock::start(config);\n    }\n\n    #[cfg(target_os = \"macos\")]\n    return macos::start(config);\n    #[cfg(target_os = \"linux\")]\n    return linux::start(config);\n    #[cfg(windows)]\n    return windows::start(config);\n    #[cfg(not(any(target_os = \"macos\", target_os = \"linux\", windows)))]\n    anyhow::bail!(\"Service management is supported on macOS, Linux, and Windows only\")\n}\n\npub fn stop(config: &Config) -> Result<ServiceStatus> {","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/openhuman/platform/service/core.rs#L31-L67","documentation":"platform::service::install registers the background service per OS (launchd on macOS, systemd on Linux, the Windows service manager); every platform arm is #[cfg]-gated, and on any other target the trailing cfg(not(any(macos, linux, windows))) arm compiles to this bail. A runtime mock (OPENHUMAN_SERVICE_MOCK) short-circuits before the platform arms, which is the sanctioned way to exercise install in tests on any OS.","triggerScenarios":"Compiling or running the service-install path on a non-macOS/Linux/Windows target — BSD, Android, wasm — e.g. cross-compiled CI binaries or porting efforts, without the mock env var set.","commonSituations":"Cross-compilation checks; ports to exotic targets; test binaries built for unusual targets where the author forgot the mock switch.","solutions":["Run service management only on the supported desktop OSes; gate callers with a cfg or runtime OS check.","For tests on any platform, set OPENHUMAN_SERVICE_MOCK=1 (optionally OPENHUMAN_SERVICE_MOCK_STATE_FILE) to route install to the in-memory mock.","For a genuine port, implement a platform module behind a new cfg arm rather than calling the stub."],"exampleFix":"// before (running on an unsupported target)\nservice::install(&config)?; // bails\n\n// after — tests on any OS: route to the mock\nstd::env::set_var(\"OPENHUMAN_SERVICE_MOCK\", \"1\");\nservice::install(&config)?;","handlingStrategy":"validation","validationCode":"fn service_management_supported() -> bool {\n    matches!(std::env::consts::OS, \"macos\" | \"linux\" | \"windows\")\n}","typeGuard":null,"tryCatchPattern":"Catch the bail and translate it to a UI 'not supported on this platform' notice; for tests, the OPENHUMAN_SERVICE_MOCK env var is the sanctioned way to exercise install on any OS.","preventionTips":["Expose service controls only on supported OSes.","Use OPENHUMAN_SERVICE_MOCK=1 (and OPENHUMAN_SERVICE_MOCK_STATE_FILE) for CI/tests on any platform.","Remember every service operation carries the same trailing bail when adding new call sites."],"tags":["service","platform-support","unsupported-os","install"],"backgroundTag":"unsupported-platform","analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}