SeleniumHQ/selenium · error · Errno::ENOENT
#{model}
Error message
#{model} What it means
ProfileHelper#verify_model validates a profile directory path used by browser profiles (Chrome/Firefox). It raises Errno::ENOENT when the path does not exist, and Errno::ENOTDIR when the path exists but is not a directory. The error message is the path string itself. A nil model short-circuits and returns without error.
Source
Thrown at rb/lib/selenium/webdriver/common/profile_helper.rb:66
end
private
def create_tmp_copy(directory)
tmp_directory = Dir.mktmpdir('webdriver-rb-profilecopy')
# TODO: must be a better way..
FileUtils.rm_rf tmp_directory
FileUtils.mkdir_p File.dirname(tmp_directory), mode: 0o700
FileUtils.cp_r directory, tmp_directory
tmp_directory
end
def verify_model(model)
return unless model
raise Errno::ENOENT, model unless File.exist?(model)
raise Errno::ENOTDIR, model unless File.directory?(model)
model
end
module ClassMethods
def from_json(json)
data = decoded(json)
Tempfile.create do |zip_path|
File.open(zip_path, 'wb') { |zip_file| zip_file << Base64.decode64(data) }
new Zipper.unzip(zip_path)
end
end
end # ClassMethods
end # ProfileHelper
end # WebDriverView on GitHub (pinned to aa36b38e69)
Solutions
- Ensure the profile path exists and is a directory: File.directory?(path).
- Use an absolute path to the profile directory.
- Pass nil if you want to skip the model check and use a default/temporary profile.
Example fix
# before
profile = Selenium::WebDriver::Chrome::Profile.new('/missing/path')
# after
profile = Selenium::WebDriver::Chrome::Profile.new('/absolute/path/to/profile')
# or nil to skip
profile = Selenium::WebDriver::Chrome::Profile.new(nil) Defensive patterns
Strategy: validation
Validate before calling
raise Errno::ENOENT, path unless model.nil? || File.exist?(model) raise Errno::ENOTDIR, path unless model.nil? || File.directory?(model)
Type guard
def valid_profile_dir?(path) path.nil? || (File.exist?(path) && File.directory?(path)) end
Try / catch
begin profile = Selenium::WebDriver::Firefox::Profile.new(model) rescue Errno::ENOENT, Errno::ENOTDIR profile = Selenium::WebDriver::Firefox::Profile.new(nil) end
Prevention
- Use absolute paths for profile directories.
- Check File.directory?(path) before constructing a Profile.
- Pass nil to use a default/temporary profile when the path is uncertain.
When it happens
Trigger: Passing a non-existent profile directory path to a Firefox/Chrome Profile. Pointing the profile at a file rather than a directory. The profile directory was deleted or moved after configuration.
Common situations: Hard-coding a profile path that differs across machines. Copying a profile config without copying the directory. Path resolved relative to the wrong working directory.
Related errors
- could not find extension at #{path.inspect}
- Add-on path does not exist: {addon_path}
- could not find extension at #{path.inspect}
- not a file: #{path.inspect}
- not executable: #{path.inspect}
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/027df62de61178fa.
Report an issue: GitHub.