SeleniumHQ/selenium · error · Error::WebDriverError

could not find extension at #{path.inspect}

Error message

could not find extension at #{path.inspect}

What it means

Raised by Firefox::Extension.new (Error::WebDriverError) when the given path does not exist on disk (File.exist?(path) is false). The constructor expects a real directory or an archive file (.xpi/.zip) for the Firefox extension to install.

Source

Thrown at rb/lib/selenium/webdriver/firefox/extension.rb:31

# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

module Selenium
  module WebDriver
    module Firefox
      #
      # @api private
      #

      class Extension
        NAMESPACE = 'http://www.mozilla.org/2004/em-rdf#'

        def initialize(path)
          raise Error::WebDriverError, "could not find extension at #{path.inspect}" unless File.exist?(path)

          @path             = path
          @should_reap_root = false
        end

        def write_to(extensions_dir)
          root_dir = create_root
          ext_path = File.join extensions_dir, read_id(root_dir)

          FileUtils.rm_rf ext_path
          FileUtils.mkdir_p File.dirname(ext_path), mode: 0o700
          FileUtils.cp_r root_dir, ext_path

          FileReaper.reap(root_dir) if @should_reap_root
        end

        private

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Verify the path with File.exist?(path) before constructing the Extension / calling add_extension.
  2. Use an absolute path (File.expand_path) so resolution does not depend on the current working directory.
  3. Confirm the extension file is actually packaged/copied into the expected location in CI.

Example fix

// before
profile.add_extension('extensions/myext.xpi')  # file missing in CI

// after
ext_path = File.expand_path('extensions/myext.xpi', __dir__)
raise "extension not found: #{ext_path}" unless File.exist?(ext_path)
profile.add_extension(ext_path)
Defensive patterns

Strategy: validation

Validate before calling

ext_path = File.expand_path(path)
raise "extension missing: #{ext_path}" unless File.exist?(ext_path)
profile.add_extension(ext_path)

Prevention

When it happens

Trigger: Calling Profile#add_extension(path) or installing an addon with a path that points to a nonexistent file/directory; a typo in the path; a relative path resolved against the wrong working directory.

Common situations: Bundled extension path computed at runtime that doesn't match the deployed layout; CI running from a different working directory than local; path built via string interpolation that yields nil (e.g. "#{nil}/ext.xpi").

Related errors


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