SeleniumHQ/selenium · error · Error::WebDriverError
unknown os: #{host_os.inspect}
Error message
unknown os: #{host_os.inspect} What it means
Platform.os infers the operating system from RbConfig::CONFIG['host_os'] using a series of regexes (Windows, macOS, Linux, Solaris/BSD). If none match, it raises WebDriverError with the unrecognized host_os string. This is a low-level detection routine relied upon by many platform-specific code paths.
Source
Thrown at rb/lib/selenium/webdriver/common/platform.rb:49
end
def engine
@engine ||= RUBY_ENGINE.to_sym
end
def os
host_os = RbConfig::CONFIG['host_os']
@os ||= case host_os
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
:windows
when /darwin|mac os/
:macosx
when /linux/
:linux
when /solaris|bsd/
:unix
else
raise Error::WebDriverError, "unknown os: #{host_os.inspect}"
end
end
def ci
if ENV['JENKINS']
:jenkins
elsif ENV['APPVEYOR']
:appveyor
elsif ENV['GITHUB_ACTIONS']
:github
end
end
def jruby?
engine == :jruby
end
def truffleruby?View on GitHub (pinned to aa36b38e69)
Solutions
- Run Selenium on a supported OS: Windows, macOS, Linux, Solaris, or BSD.
- If you must run on another OS, monkey-patch Platform.os to return a sensible value, or contribute a regex for your host_os.
- Check RbConfig::CONFIG['host_os'] on the target machine to understand why detection failed.
Defensive patterns
Strategy: validation
Validate before calling
host_os = RbConfig::CONFIG['host_os']
unless /mswin|msys|mingw|cygwin|bccwin|wince|emc|darwin|mac os|linux|solaris|bsd/ =~ host_os
warn "unsupported host_os: #{host_os}"
end Try / catch
begin
Selenium::WebDriver::Platform.os
rescue Selenium::WebDriver::Error::WebDriverError => e
raise unless e.message.include?('unknown os')
:linux # assume a fallback
end Prevention
- Run Selenium on a mainstream supported OS.
- Log RbConfig::CONFIG['host_os'] early in CI to catch detection issues.
- Monkey-patch Platform.os only as a last resort on niche systems.
When it happens
Trigger: Running on an OS whose host_os string is not covered, e.g. Haiku, AIX, some niche BSD variants, or an embedded platform. A Ruby build reporting an unusual host_os value.
Common situations: Running Selenium on a non-mainstream or experimental OS. CI on an unusual container image. This is extremely rare on Windows/macOS/Linux.
Related errors
- unsupported platform: #{Platform.os}
- Unsupported platform/architecture combination: {sys.platform
- Unable to obtain #{@service.class::EXECUTABLE}
- not a file: #{path.inspect}
- not executable: #{path.inspect}
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/1768875b44b26a62.
Report an issue: GitHub.