{"record":{"id":"0aba75801af89ce3","repo":"openai/codex","slug":"codex-app-server-daemon-lifecycle-is-only-supporte","errorCode":null,"errorMessage":"codex app-server daemon lifecycle is only supported on Unix platforms","messagePattern":"codex app-server daemon lifecycle is only supported on Unix platforms","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/app-server-daemon/src/lib.rs","lineNumber":248,"sourceCode":"    ensure_supported_platform()?;\n    Daemon::from_environment()?.set_remote_control(mode).await\n}\n\npub async fn run_pid_update_loop(\n    http_client_factory: codex_http_client::HttpClientFactory,\n) -> Result<()> {\n    ensure_supported_platform()?;\n    update_loop::run(http_client_factory).await\n}\n\n#[cfg(unix)]\nfn ensure_supported_platform() -> Result<()> {\n    Ok(())\n}\n\n#[cfg(not(unix))]\nfn ensure_supported_platform() -> Result<()> {\n    Err(anyhow!(\n        \"codex app-server daemon lifecycle is only supported on Unix platforms\"\n    ))\n}\n\nstruct Daemon {\n    socket_path: PathBuf,\n    pid_file: PathBuf,\n    update_pid_file: PathBuf,\n    operation_lock_file: PathBuf,\n    settings_file: PathBuf,\n    managed_codex_bin: PathBuf,\n}\n\nimpl Daemon {\n    fn from_environment() -> Result<Self> {\n        let codex_home = find_codex_home().context(\"failed to resolve CODEX_HOME\")?;\n        let socket_path = app_server_control_socket_path(codex_home.as_path())?\n            .as_path()","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/app-server-daemon/src/lib.rs#L230-L266","documentation":"This is the umbrella platform gate: every public entry point of codex_app_server_daemon (run, bootstrap, ensure_remote_control_ready, enable_remote_control_on_socket, start_remote_control_pairing, set_remote_control, run_pid_update_loop) calls ensure_supported_platform() first, and on non-Unix targets it returns exactly this error. The Unix-only backend stubs ([40]-[43]) sit behind it, so normally you see this message instead of theirs because it fires first.","triggerScenarios":"Calling any of the crate's public lifecycle APIs on a non-Unix target — e.g. a Windows build of a CLI dispatching 'codex app-server daemon start' or the pid update loop. On Unix the twin at lib.rs:242 returns Ok(()) and never errors.","commonSituations":"Windows dev machines or CI runners exercising daemon subcommands; cross-compiled binaries shipped to non-Unix hosts; feature-gating mistakes that compile daemon code into a Windows build.","solutions":["Run the daemon lifecycle on macOS/Linux/WSL — the whole lifecycle (signals, flock, Unix sockets, setsid) is Unix-only.","Gate call sites or CLI subcommands with #[cfg(unix)] so Windows builds never dispatch into the daemon.","Fail early with your own message when cfg!(unix) is false instead of propagating this one from deep in the call.","In shared code, return a no-op or 'unsupported here' result on non-Unix platforms."],"exampleFix":"// before: dispatched on every platform\ncodex_app_server_daemon::run(cmd).await?;\n\n// after: compile-time gate in the CLI\n#[cfg(unix)]\ncodex_app_server_daemon::run(cmd).await?;\n#[cfg(not(unix))]\nanyhow::bail!(\"app-server daemon is unavailable on this platform\");","handlingStrategy":"validation","validationCode":"// before any daemon API\nif !cfg!(unix) {\n    return Err(anyhow::anyhow!(\"daemon lifecycle unsupported on this platform\"));\n}","typeGuard":null,"tryCatchPattern":"Don't catch — branch on cfg!(unix) at the call site and skip daemon functionality on non-Unix targets; the error carries no recoverable state.","preventionTips":["cfg-gate daemon subcommands out of non-Unix CLI surfaces.","Add a non-Unix target to CI to catch unplanned daemon usage early.","Document the Unix-only requirement wherever the daemon API is exposed."],"tags":["rust","codex","daemon","platform-support","windows"],"backgroundTag":"unsupported-platform","analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}