{"record":{"id":"6ca0199af7cde25d","repo":"SeleniumHQ/selenium","slug":"could-not-find-extension-at-path-inspect","errorCode":null,"errorMessage":"could not find extension at #{path.inspect}","messagePattern":"could not find extension at #(.+?)","errorType":"exception","errorClass":"Error::WebDriverError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/chromium/options.rb","lineNumber":253,"sourceCode":"            options['args'] ||= []\n            options['args'] << \"--user-data-dir=#{@profile.directory}\"\n          end\n\n          return if (@encoded_extensions + @extensions).empty?\n\n          options['extensions'] = @encoded_extensions + @extensions.map { |ext| encode_extension(ext) }\n        end\n\n        def binary_path\n          Chrome.path\n        end\n\n        def encode_extension(path)\n          File.open(path, 'rb') { |crx_file| Base64.strict_encode64 crx_file.read }\n        end\n\n        def validate_extension(path)\n          raise Error::WebDriverError, \"could not find extension at #{path.inspect}\" unless File.file?(path)\n          raise Error::WebDriverError, \"file was not an extension #{path.inspect}\" unless File.extname(path) == '.crx'\n\n          @extensions << path\n        end\n\n        def camelize?(key)\n          !%w[localState prefs].include?(key)\n        end\n      end # Options\n    end # Chromium\n  end # WebDriver\nend # Selenium\n","sourceCodeStart":235,"sourceCodeEnd":266,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/chromium/options.rb#L235-L266","documentation":"Chromium Options#add_extension validates the path before queuing it for Base64 encoding on session creation. It raises Error::WebDriverError if no regular file exists at the given path (File.file? is false). A separate check then requires the .crx extension. Only real .crx files are accepted.","triggerScenarios":"Calling options.add_extension('/path/to/ext') where the path does not exist, points to a directory, or is otherwise not a regular file.","commonSituations":"Relative path resolved against the wrong working directory, packaging the gem without bundling the .crx, typo in the path, file deleted between runs, CI running from a different cwd than local.","solutions":["Use an absolute path to the .crx file: options.add_extension(File.expand_path('ext.crx', __dir__)).","Verify File.file?(path) before calling, and that the extension is .crx.","Ensure the .crx is packaged with your app/gem and deployed to the runtime environment.","Prefer add_encoded_extension with a pre-encoded Base64 string if the file location varies."],"exampleFix":"// before\noptions.add_extension('vendor/ext.crx')\n// after\noptions.add_extension(File.expand_path('vendor/ext.crx', __dir__))","handlingStrategy":"validation","validationCode":"def crx_file?(path)\n  File.file?(path) && File.extname(path) == '.crx'\nend\n\nraise 'not a .crx file' unless crx_file?(path)\noptions.add_extension(path)","typeGuard":"def valid_extension_path?(path)\n  File.file?(path) && File.extname(path).casecmp?('.crx')\nend","tryCatchPattern":"begin\n  options.add_extension(path)\nrescue Selenium::WebDriver::Error::WebDriverError => e\n  raise unless e.message =~ /could not find extension/\n  options.add_extension(File.expand_path('ext.crx', __dir__))\nend","preventionTips":["Always use absolute paths for extension files.","Bundle the .crx with your gem/app and verify it exists at runtime.","Prefer add_encoded_extension when the file location is unstable."],"tags":["chromium","extension","filesystem","options","ruby"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}