-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Type: Bug
Title:
getActiveInterpreter Does Not Return User-Selected Interpreter When Stored in Workspace Storage
Description:
In recent versions of the VS Code Python extension, the user-selected Python interpreter is saved in VS Code’s workspace storage instead of settings.json or the pythonPath config. However, the current implementation of InterpreterService.getActiveInterpreter (see src/client/interpreter/interpreterService.ts) still attempts to retrieve the active interpreter path from the configuration service (configService.getSettings().pythonPath). As a result, when a user manually selects an interpreter, this method may not return the actual active interpreter, but rather a default or outdated path.
Steps to Reproduce:
- In VS Code, manually select a Python interpreter for your workspace.
- Check that the selected interpreter is not written to
.vscode/settings.jsonor globalsettings.json. - Use code that calls
InterpreterService.getActiveInterpreterto query the current interpreter. - Observe that the returned path is from the old config (or just
"python"), not the actual selected interpreter.
Expected Behavior:
getActiveInterpreter should return the interpreter that the user has selected, regardless of whether it is stored in workspace storage or in the traditional configuration.
Actual Behavior:
getActiveInterpreter may return a value from the old config, which does not always reflect the user’s current selection.
Possible Solution:
Update InterpreterService.getActiveInterpreter to retrieve the active interpreter from workspace storage or use the correct API provided by the Python extension, rather than relying solely on the pythonPath setting.
Relevant Code:
src/client/interpreter/interpreterService.ts
public async getActiveInterpreter(resource?: Uri): Promise<PythonEnvironment | undefined> {
// ...
path = this.configService.getSettings(resource).pythonPath;
// ...
}Environment:
- VS Code Python extension version: [fill in]
- VS Code version: [fill in]
- OS: [fill in]
Additional Context:
This could lead to inconsistencies or confusion for users and extensions relying on this method to determine the active interpreter.
--
Extension version: 2025.6.1
VS Code version: Code 1.100.2 (Universal) (848b80aeb52026648a8ff9f7c45a9b0a80641e2e, 2025-05-14T21:47:40.416Z)
OS version: Darwin arm64 24.1.0
Modes:
- Python version (& distribution if applicable, e.g. Anaconda):
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Unknown
- Value of the
python.languageServersetting: Default
User Settings
languageServer: "Pylance"
Installed Extensions
| Extension Name | Extension Id | Version |
|---|---|---|
| debugpy | ms- | 2025.8.0 |
| js-debug | ms- | 1.100.1 |
| js-debug-companion | ms- | 1.1.3 |
| python | ms- | 2025.6.1 |
| rust-analyzer | rus | 0.3.2466 |
| vscode-js-profile-table | ms- | 1.0.10 |
| vscode-pylance | ms- | 2025.5.1 |
System Info
| Item | Value |
|---|---|
| CPUs | Apple M1 Pro (10 x 2400) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: enabled_on 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 skia_graphite: disabled_off video_decode: enabled video_encode: enabled webgl: enabled webgl2: enabled webgpu: enabled webnn: disabled_off |
| Load (avg) | 4, 4, 5 |
| Memory (System) | 32.00GB (0.14GB free) |
| Process Argv | --crash-reporter-id 1870487a-4838-483f-86f3-4e868bb1f593 |
| Screen Reader | no |
| VM | 0% |
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
vscaac:30438847
c4g48928:30535728
azure-dev_surveyone:30548225
2i9eh265:30646982
962ge761:30959799
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dwnewjupyter:31046869
pythonrstrctxt:31112756
nativeloc2:31192216
5fd0e150:31155592
dwcopilot:31170013
6074i472:31201624
dwoutputs:31242946
customenabled:31248079
9064b325:31222308
copilot_t_ci:31222730
e5gg6876:31282496
pythoneinst12:31285622
bgtreat:31268568
4gafe986:31271826
c7cif404:31309971
996jf627:31283433
pythonrdcb7:31303018
usemplatestapi:31297334
0aa6g176:31307128
7bj51361:31289155
747dc170:31275177
pylancecolor:31309108
aj953862:31281341
generatesymbolt:31295002
convertfstringf:31295003
gendocf:31295004
j6a0c355:31309728