SergeyPirogov / webdriver_manager

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chrome download permission errors - HOME variable dependency

david-engelmann opened this issue · comments

I've recently started seeing permission errors when running with the ChromeDriverManager

    self.driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
  File "/opt/venv/lib/python3.8/site-packages/webdriver_manager/chrome.py", line 40, in install
    driver_path = self._get_driver_binary_path(self.driver)
  File "/opt/venv/lib/python3.8/site-packages/webdriver_manager/core/manager.py", line 41, in _get_driver_binary_path
    binary_path = self._cache_manager.save_file_to_cache(driver, file)
  File "/opt/venv/lib/python3.8/site-packages/webdriver_manager/core/driver_cache.py", line 53, in save_file_to_cache
    archive = self.save_archive_file(file, path)
  File "/opt/venv/lib/python3.8/site-packages/webdriver_manager/core/driver_cache.py", line 46, in save_archive_file
    return self._file_manager.save_archive_file(file, path)
  File "/opt/venv/lib/python3.8/site-packages/webdriver_manager/core/file_manager.py", line 45, in save_archive_file
    os.makedirs(directory, exist_ok=True)
  File "/usr/lib/python3.8/os.py", line 213, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/usr/lib/python3.8/os.py", line 213, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/usr/lib/python3.8/os.py", line 213, in makedirs
    makedirs(head, exist_ok=exist_ok)
  [Previous line repeated 2 more times]
  File "/usr/lib/python3.8/os.py", line 223, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/nonexistent'

It's attempting to save to a directory "nonexistent" that doesn't exist. I'm investigating the issue now

I'm getting the following error messages in the DriverCacheManager class

"save_archive_file" is not a known member of "None"

"unpack_archive" is not a known member of "None"

It appears the in the DriverCacheManager initialization that the case of file_manager=None, which is the default parameter is not working correctly.

If the file_manager is passed as none it's suppose to run the following line

self._file_manager = FileManager(self._os_system_manager)

It appears that there are some linting errors occurs in the following block.

        try:
            cmd_mapping = cmd_mapping[browser_type][
                OperationSystemManager.get_os_name()
            ]
            pattern = PATTERN[browser_type]
            version = read_version_from_cmd(cmd_mapping, pattern)
            return version
        except Exception:
            return None

I've narrowed the issue down to the setting of DEFAULT_USER_HOME_CACHE_PATH. it uses the following function

os.path.expanduser("~")

that is currently returning /nonexistent. Seems like an effect of setting the user to nobody in docker-compose. the permission issue basically comes down to the setting of the HOME variable