Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when searching for Python under WSL #111

Closed
silasary opened this issue Nov 13, 2021 · 4 comments
Closed

Crash when searching for Python under WSL #111

silasary opened this issue Nov 13, 2021 · 4 comments

Comments

@silasary
Copy link

When trying to find all versions of python, it explores into the Windows environment (which isn't ideal regardless), but if you have the Windows Store version of Python installed, we get a lovely crash when trying to probe /mnt/c/WINDOWS/system32/config/systemprofile/AppData/Local/Microsoft/WindowsApps

PS C:\Users\Clock> wsl
silasary@GARCHOMP:/mnt/e/source/repos/Penny-Dreadful-Tools$ python
Python 3.8.10 (default, Sep 28 2021, 16:10:42)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pythonfinder import Finder
>>> f = Finder()
>>> f.find_python_version(3, minor=8)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/silasary/.local/lib/python3.8/site-packages/pythonfinder/pythonfinder.py", line 288, in find_python_version
    return self.system_path.find_python_version(
  File "/home/silasary/.local/lib/python3.8/site-packages/pythonfinder/pythonfinder.py", line 120, in system_path
    self._system_path = self.create_system_path()
  File "/home/silasary/.local/lib/python3.8/site-packages/pythonfinder/pythonfinder.py", line 82, in create_system_path
    return pyfinder_path.SystemPath.create(
  File "/home/silasary/.local/lib/python3.8/site-packages/pythonfinder/models/path.py", line 667, in create
    {
  File "/home/silasary/.local/lib/python3.8/site-packages/pythonfinder/models/path.py", line 672, in <dictcomp>
    if p.exists()
  File "/usr/lib/python3.8/pathlib.py", line 1407, in exists
    self.stat()
  File "/usr/lib/python3.8/pathlib.py", line 1198, in stat
    return self._accessor.stat(self)
PermissionError: [Errno 13] Permission denied: '/mnt/c/WINDOWS/system32/config/systemprofile/AppData/Local/Microsoft/WindowsApps'
>>>
silasary@GARCHOMP:/mnt/e/source/repos/Penny-Dreadful-Tools$ echo $PATH
/home/silasary/.local/bin:/home/silasary/.nvm/versions/node/v16.10.0/bin:/home/silasary/.sdkman/candidates/gradle/current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files/WindowsApps/Microsoft.WindowsTerminal_1.11.2921.0_x64__8wekyb3d8bbwe:/mnt/c/Program Files (x86)/Razer/ChromaBroadcast/bin:/mnt/c/Program Files/Razer/ChromaBroadcast/bin:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/Git/cmd:/mnt/c/WINDOWS/system32/config/systemprofile/AppData/Local/Microsoft/WindowsApps:/mnt/c/Program Files/mGBA:/mnt/c/Program Files/dotnet/:/mnt/c/Program Files (x86)/IncrediBuild:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/ProgramData/DockerDesktop/version-bin:/mnt/c/Program Files (x86)/GitExtensions/:/mnt/c/Program Files/nodejs/:/mnt/c/Users/Clock/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/Clock/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Program Files (x86)/GitHub CLI/:/mnt/c/Users/Clock/.dotnet/tools:/mnt/c/Users/Clock/AppData/Local/Programs/Python/Python310/Scripts:/mnt/c/Users/Clock/AppData/Roaming/npm:/snap/bin
@silasary silasary changed the title Bug when searching for Python under WSL Crash when searching for Python under WSL Nov 13, 2021
@bendog
Copy link

bendog commented Nov 25, 2021

This bug also affects Windows native, not just WSL2

@bendog
Copy link

bendog commented Nov 25, 2021

Temporary fix, is to give your user access to READ + LIST for the windows folders which are triggering this error.

@frostming
Copy link
Member

Fixed by #112

@Tikkoneus
Copy link

I don't believe #112 fixes this issue. The exception isn't caught by exists_and_is_accessible because the exception occurs in pathlib when generating the arguments which go to exists_and_is_accessible:

From pythonfinder 2.1.0:

 File ".pyenv\pyenv-win\versions\3.8.6\lib\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 185, in <listcomp>
    if exists_and_is_accessible(Path(p.strip('"')).resolve())
  File ".pyenv\pyenv-win\versions\3.8.6\lib\pathlib.py", line 1180, in resolve
    s = self._flavour.resolve(self, strict=strict)
  File ".pyenv\pyenv-win\versions\3.8.6\lib\pathlib.py", line 205, in resolve
    s = self._ext_to_normal(_getfinalpathname(s))
PermissionError: [WinError 5] Access is denied: 'C:\\Windows\\System32\\config\\systemprofile\\AppData\\Local\\Microsoft'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants