Access is denied: 'C:\WINDOWS\system32\config\systemprofile' in pythonfinder.Finder
#6093
Labels
Type: Vendored Dependencies
This issue affects vendored dependencies within pipenv.
Issue description
The
pythonfinder.Finder
dataclass, which tries to search all paths on thePATH
environment variable somehow tries to access some system32 folders and throws an exception when that is not accessible. This happens with every pipenv call that tries gather information on the installed python versions, which means evenpipenv --support
broke.Expected result
As I gave the
--python
option with a path to mypython.exe
on the commandline, I expected pipenv to completely ignore the pathsearch in the first place.When I don't give that option, I expect the pathsearch to skip non-accessible paths.
Actual result
Steps to replicate
A simple
pipenv install
will do on my system (Windows 10, Python 3.9.5, pipenv 2023.12.1).Minimal pipfile:
My PATH env variable:
I added the closing
</details>
tag manually!$ pipenv --support
Pipenv version:
'2023.12.1'
Pipenv location:
'C:\\toolbase\\python\\3.9.5.0.0\\python-3.9.5.amd64\\lib\\site-packages\\pipenv'
Python location:
'C:\\toolbase\\python\\3.9.5.0.0\\python-3.9.5.amd64\\python.exe'
OS Name:
'nt'
User pip version:
'23.3.2'
user Python installations found:
Traceback (most recent call last):
File "C:\toolbase\python\3.9.5.0.0\python-3.9.5.amd64\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\toolbase\python\3.9.5.0.0\python-3.9.5.amd64\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\toolbase\python\3.9.5.0.0\python-3.9.5.amd64\Scripts\pipenv.exe_main.py", line 7, in
# when invoked as python -m pip
File "C:\toolbase\python\3.9.5.0.0\python-3.9.5.amd64\lib\site-packages\pipenv\vendor\click\core.py", line 1157, in call
return self.main(*args, **kwargs)
File "C:\toolbase\python\3.9.5.0.0\python-3.9.5.amd64\lib\site-packages\pipenv\cli\options.py", line 58, in main
return super().main(*args, **kwargs, windows_expand_args=False)
File "C:\toolbase\python\3.9.5.0.0\python-3.9.5.amd64\lib\site-packages\pipenv\vendor\click\core.py", line 1078, in main
rv = self.invoke(ctx)
File "C:\toolbase\python\3.9.5.0.0\python-3.9.5.amd64\lib\site-packages\pipenv\vendor\click\core.py", line 1666, in invoke
rv = super().invoke(ctx)
File "C:\toolbase\python\3.9.5.0.0\python-3.9.5.amd64\lib\site-packages\pipenv\vendor\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\toolbase\python\3.9.5.0.0\python-3.9.5.amd64\lib\site-packages\pipenv\vendor\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "C:\toolbase\python\3.9.5.0.0\python-3.9.5.amd64\lib\site-packages\pipenv\vendor\click\decorators.py", line 92, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "C:\toolbase\python\3.9.5.0.0\python-3.9.5.amd64\lib\site-packages\pipenv\vendor\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "C:\toolbase\python\3.9.5.0.0\python-3.9.5.amd64\lib\site-packages\pipenv\vendor\click\decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
File "C:\toolbase\python\3.9.5.0.0\python-3.9.5.amd64\lib\site-packages\pipenv\cli\command.py", line 134, in cli
get_pipenv_diagnostics(state.project)
File "C:\toolbase\python\3.9.5.0.0\python-3.9.5.amd64\lib\site-packages\pipenv\help.py", line 32, in get_pipenv_diagnostics
finder = pythonfinder.Finder(system=False, global_search=True)
File "", line 8, in init
File "C:\toolbase\python\3.9.5.0.0\python-3.9.5.amd64\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 24, in post_init
self.system_path = self.create_system_path()
File "C:\toolbase\python\3.9.5.0.0\python-3.9.5.amd64\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 30, in create_system_path
return SystemPath.create(
File "C:\toolbase\python\3.9.5.0.0\python-3.9.5.amd64\lib\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 544, in create
instance._run_setup()
File "C:\toolbase\python\3.9.5.0.0\python-3.9.5.amd64\lib\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 182, in _run_setup
path_instances = [
File "C:\toolbase\python\3.9.5.0.0\python-3.9.5.amd64\lib\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 185, in
if exists_and_is_accessible(Path(p.strip('"')).resolve())
File "C:\toolbase\python\3.9.5.0.0\python-3.9.5.amd64\lib\pathlib.py", line 1205, in resolve
s = self._flavour.resolve(self, strict=strict)
File "C:\toolbase\python\3.9.5.0.0\python-3.9.5.amd64\lib\pathlib.py", line 206, in resolve
s = self._ext_to_normal(_getfinalpathname(s))
PermissionError: [WinError 5] Access is denied: 'C:\WINDOWS\system32\config\systemprofile'
The text was updated successfully, but these errors were encountered: