SeleniumHQ/selenium · error · Errno::ENOENT

{}

Error message

{}

What it means

Raised in Selenium::Server.new (server.rb:185) when the jar path passed in does not exist on disk; it raises Errno::ENOENT with the jar path as the message. The documented contract (@raise [Errno::ENOENT]) makes this an explicit precondition check.

Source

Thrown at rb/lib/selenium/server.rb:185

    # :standalone, #hub, #node
    #

    attr_accessor :role, :host, :port, :timeout, :background, :log

    #
    # @param [String] jar Path to the server jar.
    # @param [Hash] opts the options to create the server process with
    #
    # @option opts [Integer] :port Port the server should listen on (default: 4444).
    # @option opts [Integer] :timeout Seconds to wait for server launch/shutdown (default: 30)
    # @option opts [true,false] :background Run the server in the background (default: false)
    # @option opts [true,false,String] :log Either a path to a log file,
    #                                      or true to pass server log to stdout.
    # @raise [Errno::ENOENT] if the jar file does not exist
    #

    def initialize(jar, opts = {})
      raise Errno::ENOENT, jar unless File.exist?(jar)

      @java = opts.fetch(:java, 'java') || 'java'
      @jar = jar
      @host = '127.0.0.1'
      @role = opts.fetch(:role, 'standalone')
      @port = opts.fetch(:port, WebDriver::PortProber.above(4444))
      @timeout = opts.fetch(:timeout, 30)
      @background = opts.fetch(:background, false)
      @additional_args = opts.fetch(:args, [])
      @log = opts[:log]
      if opts[:log_level]
        @log ||= true
        @additional_args << '--log-level'
        @additional_args << opts[:log_level].to_s
      end

      @log_file = nil
    end

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Confirm the jar path exists (File.exist?(jar)) before constructing the Server.
  2. Let Selenium download the jar (Selenium::Server.download) instead of supplying a path you are unsure about.
  3. Use an absolute path to the jar.

Example fix

# before
server = Selenium::Server.new('selenium-server.jar')  # not present
# after
jar = Selenium::Server.download(:latest)
server = Selenium::Server.new(jar, port: 4444)
Defensive patterns

Strategy: validation

Validate before calling

raise ArgumentError, "jar not found: #{jar}" unless File.exist?(jar)
server = Selenium::Server.new(jar, opts)

Prevention

When it happens

Trigger: File.exist?(jar) is false at server.rb:185, i.e. the jar argument points to a non-existent file.

Common situations: The jar was never downloaded; wrong path/typo; relative path resolved against an unexpected cwd; the download step was skipped.

Related errors


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