SeleniumHQ/selenium · error · anyhow::Error

Invalid operating system: {os}

Error message

Invalid operating system: {os}

What it means

Returned by str_to_os() in rust/src/config.rs when the supplied OS string does not match any alias of the WINDOWS, MACOS, or LINUX enum variants (windows/win, macos/mac, linux/gnu/linux). It is the canonical mapping failure when Selenium Manager cannot classify the runtime or a user-supplied OS value.

Source

Thrown at rust/src/config.rs:175

            LINUX => vec!["linux", "gnu/linux"],
        }
    }

    pub fn is(&self, os: &str) -> bool {
        self.to_str_vector()
            .contains(&os.to_ascii_lowercase().as_str())
    }
}

pub fn str_to_os(os: &str) -> Result<OS, Error> {
    if WINDOWS.is(os) {
        Ok(WINDOWS)
    } else if MACOS.is(os) {
        Ok(MACOS)
    } else if LINUX.is(os) {
        Ok(LINUX)
    } else {
        Err(anyhow!(format!("Invalid operating system: {os}")))
    }
}

/// Processor architecture families used by the manager.
#[allow(dead_code)]
#[allow(clippy::upper_case_acronyms)]
pub enum ARCH {
    X32,
    X64,
    ARM64,
    ARMV7,
}

impl ARCH {
    /// Returns the known string aliases for this architecture.
    pub fn to_str_vector(&self) -> Vec<&str> {
        match self {
            ARCH::X32 => vec![ARCH_X86, "i386", "x32", "i686"],

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Set the OS to a supported alias: 'windows', 'macos', 'linux', 'win', 'mac', or 'gnu/linux'.
  2. Leave SE_OS unset so Selenium Manager auto-detects from std::env::consts::OS.
  3. Trim whitespace and check for stray characters in config values.
  4. If on an unsupported OS, run Selenium Manager inside a supported container/VM.

Example fix

# before (env)
export SE_OS=osx

# after
export SE_OS=macos
Defensive patterns

Strategy: validation

Validate before calling

// Rust: validate OS string before passing to str_to_os
fn is_supported_os(os: &str) -> bool {
    let l = os.to_ascii_lowercase();
    matches!(l.as_str(), "windows" | "win" | "macos" | "mac" | "linux" | "gnu/linux")
}
if !is_supported_os(&os_str) {
    return Err(anyhow!("Use one of: windows, macos, linux"));
}

Try / catch

let os = match str_to_os(&os_str) {
    Ok(o) => o,
    Err(e) if e.to_string().contains("Invalid operating system") => {
        eprintln!("Set SE_OS to windows, macos, or linux");
        return Err(e);
    }
    Err(e) => return Err(e),
};

Prevention

When it happens

Trigger: str_to_os() is called with a value like 'freebsd', 'android', 'ios', a typo ('windos'), or a case-mismatched token not normalized by OS::is (which lowercases). Happens when reading SE_OS env var or a config file with an unsupported OS.

Common situations: User sets SE_OS to an unsupported value; running on an exotic OS (BSD, Solaris); a config file specifies 'osx' (the macOS aliases are macos/mac, not osx); trailing whitespace in a config value.

Related errors


AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14). Data as JSON: /api/errors/54f6be9512e23a24. Report an issue: GitHub.