Pyright is using Incorrect Interpreter Path
Type: Bug
Behaviour
Expected vs. Actual
The python plugin sends the incorrect interpreter path to langauge server plugins such as pyright if the name of the
virtual environment name begins with "python" (e.g. python_env) (as far as I can tell from trying many different names).
For some reason this only seems to affect the name of the virtualenv itself. If the virtualenv has a path such as
/tmp/python_envs/venv/ then the plugin detects the interpreter path correctly.
Steps to reproduce:
- create the following
settings.json
{
"python.languageServer": "None",
}- install the
pythonandpyrightplugins - create a virtual environment with a name beginning with
python(e.g.python_env) - activate the virtual environment
- open vscodium in an empty directory
- create an open a
.pyfile
The output of the python plugin:
2024-01-09 21:30:31.040 [info] Telemetry level is off
2024-01-09 21:30:31.040 [info] Experiments are disabled, only manually opted experiments are active.
2024-01-09 21:30:31.065 [info] Default formatter is set to null for workspace /tmp/workspace
2024-01-09 21:30:31.073 [info] VS Code was launched from an activated environment: 'python_env', selecting it as the interpreter for workspace.
2024-01-09 21:30:31.076 [info] Test server listening.
2024-01-09 21:30:31.079 [info] Python interpreter path: ~/.virtualenvs/python_env/bin/python
2024-01-09 21:30:31.112 [info] Editor support is inactive since language server is set to None.
2024-01-09 21:30:31.159 [info] Send text to terminal: source ~/.virtualenvs/python_env/bin/activateThe output of the pyright plugin:
[Info - 21:30:31] Pyright language server 1.1.345 starting
[Info - 21:30:31] Server root directory: file:///home/matthew/.vscode-oss/extensions/ms-pyright.pyright-1.1.345/dist
[Info - 21:30:31] Starting service instance "workspace"
Received pythonPath from Python extension: /home/matthew/.virtualenvs/python_env
[Info - 21:30:31] Setting pythonPath for service "workspace": "/home/matthew/.virtualenvs/python_env"
[Info - 21:30:31] Unable to get Python version from interpreter
[Info - 21:30:31] Found 1 source filepyright is receiving the root directory of the virtualenv instead of the interpreter path.
A simple workaround is to rename the virtual environment but this is still a bug as the result is unexpected.
Diagnostic data
- Python version (& distribution if applicable, e.g. Anaconda): 3.11.6
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
- Value of the
python.languageServersetting: None
Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
XXX
languageServer: "None"
Extension version: 2023.22.1 VSCodium version: VSCodium 1.85.1 (08e6c15293922dd53a864bb041be381322fee401, 2023-12-14T20:36:42.296Z) OS version: Linux x64 6.1.71-1-lts Modes:
System Info| Item | Value |
|---|---|
| CPUs | Intel(R) Core(TM) i7-10870H CPU @ 2.20GHz (16 x 3599) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: disabled_off direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok video_decode: enabled video_encode: disabled_software vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: disabled_off |
| Load (avg) | 2, 1, 2 |
| Memory (System) | 31.05GB (21.93GB free) |
| Process Argv | --ms-enable-electron-run-as-node . |
| Screen Reader | no |
| VM | 0% |
| DESKTOP_SESSION | plasma |
| XDG_CURRENT_DESKTOP | KDE |
| XDG_SESSION_DESKTOP | KDE |
| XDG_SESSION_TYPE | x11 |
Source: microsoft/pyright