Unexpected error message "The entered path does not exist" when refreshing interpreters
Positron Version:
Positron Version: 2024.05.0 (Universal) build 1323
Steps to reproduce the issue:
- Somehow end up with a Python interpreter with a path that doesn't exist. I think in my case it was by creating a virtual environment from a base Python env, then deleting the base Python env so the venv symlink points to a non-existent file.
- Run the "Python: Select Interpreter" command, then click the refresh button (top right).
- An error message will be shown.
What did you expect to happen?
I don't think we should show the error message when interpreters are discovered, only when a user manually tries to enter a path. There already seems to be some logic hiding the interpreter from the list.
Were there any error messages in the output or Developer Tools console?
Python output channel:
2024-05-31 16:30:18.831 [error] Could not register runtime due to an invalid interpreter path: /Users/seem/.local/share/virtualenvs/positron-AMn_615p/bin/python
Following over from https://github.com/posit-dev/positron/issues/4011:
Steps that helped me reproduce:
- Create a Python Venv and open the workspace with the Venv in Positron
- Delete that Venv
- Do something that triggers interpreter discovery (e.g. refresh interpreters, create new project via project wizard, open a new folder, etc.)
- See the notification error message
Reproduced with Project Wizard
https://github.com/user-attachments/assets/2a67af09-a96c-4b14-b843-e5fcd988b198
Reproduced with "Python: Select Interpreter" QuickPick + New Folder
https://github.com/user-attachments/assets/541ce795-ce18-45d4-96cb-652843959ed2
Some Python Output
2024-07-16 11:20:59.878 [debug] No cached env found for /Users/sashimi/Documents/projects/myPythonProject/.venv/bin/python
2024-07-16 11:20:59.878 [debug] Searching for workspace virtual envs in: /Users/sashimi/Documents/projects/myPythonProject
...
2024-07-16 11:20:59.878 [warning] Failed to check if /Users/sashimi/Documents/projects/myPythonProject/.venv/bin/python is an executable [Error: ENOENT: no such file or directory, lstat '/Users/sashimi/Documents/projects/myPythonProject/.venv/bin/python'] {
errno: -2,
code: 'ENOENT',
syscall: 'lstat',
path: '/Users/sashimi/Documents/projects/myPythonProject/.venv/bin/python'
}
2024-07-16 11:20:59.878 [debug] Finished searching for workspace virtual envs
2024-07-16 11:20:59.882 [warning] Identifier for virt-virtualenv failed to identify /Users/sashimi/Documents/projects/myPythonProject/.venv/bin/python [Error: ENOENT: no such file or directory, scandir '/Users/sashimi/Documents/projects/myPythonProject/.venv/bin'] {
errno: -2,
code: 'ENOENT',
syscall: 'scandir',
path: '/Users/sashimi/Documents/projects/myPythonProject/.venv/bin'
}
2024-07-16 11:20:59.883 [debug] Failed to get file info for /Users/sashimi/Documents/projects/myPythonProject/.venv/bin/python [Error: ENOENT: no such file or directory, lstat '/Users/sashimi/Documents/projects/myPythonProject/.venv/bin/python'] {
errno: -2,
code: 'ENOENT',
syscall: 'lstat',
path: '/Users/sashimi/Documents/projects/myPythonProject/.venv/bin/python'
}
...
2024-07-16 11:20:59.931 [debug] No cached env found for /Users/sashimi/Documents/projects/myPythonProject/.venv/bin/python
2024-07-16 11:20:59.931 [info] Selected workspace /Users/sashimi/Documents/projects/myPythonProject for creating virtual environment.
2024-07-16 11:20:59.932 [error] [Error: Command failed: /Users/sashimi/Documents/projects/myPythonProject/.venv/bin/python -I /Users/sashimi/Desktop/Positron.app/Contents/Resources/app/extensions/positron-python/python_files/get_output_via_markers.py /Users/sashimi/Desktop/Positron.app/Contents/Resources/app/extensions/positron-python/python_files/interpreterInfo.py
/bin/sh: /Users/sashimi/Documents/projects/myPythonProject/.venv/bin/python: No such file or directory
at ChildProcess.exithandler (node:child_process:422:12)
at ChildProcess.emit (node:events:526:35)
at maybeClose (node:internal/child_process:1105:16)
at Socket.<anonymous> (node:internal/child_process:457:11)
at Socket.emit (node:events:514:28)
at Pipe.<anonymous> (node:net:337:12)] {
code: 127,
killed: false,
signal: null,
cmd: '/Users/sashimi/Documents/projects/myPythonProject/.venv/bin/python -I /Users/sashimi/Desktop/Positron.app/Contents/Resources/app/extensions/positron-python/python_files/get_output_via_markers.py /Users/sashimi/Desktop/Positron.app/Contents/Resources/app/extensions/positron-python/python_files/interpreterInfo.py'
}
2024-07-16 11:20:59.932 [warning] Failed to check if /Users/sashimi/Documents/projects/myPythonProject/.venv/bin/python is an executable [Error: ENOENT: no such file or directory, lstat '/Users/sashimi/Documents/projects/myPythonProject/.venv/bin/python'] {
errno: -2,
code: 'ENOENT',
syscall: 'lstat',
path: '/Users/sashimi/Documents/projects/myPythonProject/.venv/bin/python'
}
...
2024-07-16 11:21:39.904 [error] Could not register runtime due to an invalid interpreter path: /Users/sashimi/Documents/projects/myPythonProject/.venv/bin/python
I'm moving this back to triage because multiple folks have run into this in different contexts.
I think we should move the current error message out of the onDidChangeInterpreters listener (registered in the PythonRuntimeManager constructor) to the "Enter interpreter path..." sub-command of "Select Interpreters", so that it only shows if a user manually enters a path that's missing.
If interpreters are discovered with missing paths, that should be handled separately. The upstream extension already has some logic for that.
Verified Fixed
Positron Version(s) : 2024.07.0-125
OS Version : OSX
Test scenario(s)
Used Sharon's approach and did not reproduce.
Link(s) to TestRail test cases run or created: N/A