zeroclaw-labs/zeroclaw · error · anyhow::Error

the OpenRC log writer is only supported on Linux

Error message

the OpenRC log writer is only supported on Linux

What it means

run_openrc_log_writer is compiled as a stub on non-Linux targets that always bails (service/mod.rs:158-163). The OpenRC stdout/stderr log writer depends on Linux service log paths, so calling it on macOS or Windows can never succeed.

Source

Thrown at crates/zeroclaw-runtime/src/service/mod.rs:162

        {
            first_write_error = Some(error.context(format!(
                "Failed to write bounded service log {}",
                path.display()
            )));
            log = None;
        }
    }
    if let Some(error) = first_write_error {
        return Err(error);
    }
    Ok(())
}

pub fn run_openrc_log_writer(stderr: bool) -> Result<()> {
    #[cfg(not(target_os = "linux"))]
    {
        let _ = stderr;
        bail!("the OpenRC log writer is only supported on Linux")
    }

    #[cfg(target_os = "linux")]
    {
        drain_bounded_service_log(std::io::stdin().lock(), openrc_log_path(stderr))
    }
}

#[cfg(any(target_os = "linux", test))]
fn openrc_log_path(stderr: bool) -> &'static Path {
    Path::new(if stderr {
        OPENRC_STDERR_LOG
    } else {
        OPENRC_STDOUT_LOG
    })
}

#[cfg(any(target_os = "macos", test))]

View on GitHub (pinned to 88bb9c8533)

Solutions

  1. Gate the call: invoke run_openrc_log_writer only when std::env::consts::OS == "linux" (or via #[cfg(target_os = "linux")])
  2. On macOS use the launchd runner (run_launchd_daemon) instead
  3. Select the service runner from the detected OS, not from config alone

Example fix

// before
run_openrc_log_writer(stderr)?;

// after
#[cfg(target_os = "linux")]
run_openrc_log_writer(stderr)?;
#[cfg(not(target_os = "linux"))]
anyhow::bail!("openrc log writer requires Linux; this build targets {}", std::env::consts::OS);
Defensive patterns

Strategy: validation

Validate before calling

fn is_linux() -> bool {
    std::env::consts::OS == "linux"
}

if is_linux() {
    run_openrc_log_writer(stderr)?;
} else {
    tracing::warn!(os = std::env::consts::OS, "skipping openrc log writer: Linux only");
}

Type guard

fn supports_openrc() -> bool { cfg!(target_os = "linux") }

Try / catch

If the call still fails, treat 'only supported on Linux' as a dispatcher bug: log the detected OS and the runner mismatch, and route to the platform-appropriate runner instead of retrying.

Prevention

When it happens

Trigger: Invoking the OpenRC log-writer entry point on a macOS or Windows build — e.g. running the same service CLI used on the Linux host on a dev machine, or a dispatcher that chose the wrong runner for the platform.

Common situations: One binary built once and deployed to all platforms; a wrapper script picks the OpenRC path by service name instead of OS; CI runs service smoke tests on a macOS runner.

Related errors


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/df99ea6452aa9c3f. Report an issue: GitHub.