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

Service log viewing is supported on macOS, Linux, and Window

Error message

Service log viewing is supported on macOS, Linux, and Windows only

What it means

logs() dispatches to logs_macos, logs_linux (after resolving the init system) or logs_windows. Unlike the management verbs, the message correctly includes Windows; the bail fires only on remaining platforms such as the BSDs.

Source

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

            println!("Unit: /etc/init.d/{}", linux_openrc_service(config));
        }
        InitSystem::Auto => unreachable!("Auto should be resolved before this point"),
    }
    Ok(())
}

pub fn logs(config: &Config, init_system: InitSystem, lines: usize, follow: bool) -> Result<()> {
    if cfg!(target_os = "macos") {
        return logs_macos(config, lines, follow);
    }
    if cfg!(target_os = "linux") {
        let resolved = init_system.resolve()?;
        return logs_linux(config, resolved, lines, follow);
    }
    if cfg!(target_os = "windows") {
        return logs_windows(config, lines, follow);
    }
    anyhow::bail!("Service log viewing is supported on macOS, Linux, and Windows only")
}

fn logs_macos(config: &Config, lines: usize, follow: bool) -> Result<()> {
    // Try the launchd log files first (StandardOutPath / StandardErrorPath from the plist).
    // These are the most reliable source since they capture all daemon output.
    let exe = std::env::current_exe().ok();
    let homebrew_var_dir = exe.as_ref().and_then(|e| homebrew_var_dir_from_exe(e));
    let logs_dir = if let Some(ref var_dir) = homebrew_var_dir {
        var_dir.join("logs")
    } else {
        config
            .config_path
            .parent()
            .map_or_else(|| PathBuf::from("."), PathBuf::from)
            .join("logs")
    };

    let stderr_log = logs_dir.join("daemon.stderr.log");

View on GitHub (pinned to 88bb9c8533)

Solutions

  1. Read the daemon's log files directly with tail on whatever path your manual service definition uses
  2. Run the daemon in the foreground during debugging instead of relying on 'service logs'
  3. Add platform support or route logging to a file you control
Defensive patterns

Strategy: validation

Validate before calling

fn service_logs_supported() -> bool {
    cfg!(any(target_os = "macos", target_os = "linux", target_os = "windows"))
}

Prevention

When it happens

Trigger: Running 'zeroclaw service logs' on a platform where none of the three cfg! branches match.

Common situations: Attempting to tail daemon logs on FreeBSD/OpenBSD builds; scripts assuming journalctl-like tooling exists everywhere.

Related errors


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