-
Notifications
You must be signed in to change notification settings - Fork 38
Description
Description
When configuring python.defaultInterpreterPath using the ${workspaceFolder} variable (e.g., ${workspaceFolder}/.venv/bin/python), the Python Environments component fails to resolve the variable.
Based on the logs, the extension treats ${workspaceFolder} as a literal string part of the file path, causing the interpreter lookup to fail with "No such file or directory". This forces VS Code to fall back to the system global interpreter (e.g., ~/.local/bin/python) or fail environment discovery entirely.
Steps to Reproduce
- Open a workspace with a virtual environment located at
<root>/.venv. - In
.vscode/settings.json, set the default interpreter path using the variable:
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python"- Reload the window (
Developer: Reload Window). - Trigger an extension activation (e.g., open a
.pyfile or run Test Discovery). - Observe that the selected interpreter is NOT the one specified, but a fallback global one.
Expected Behavior
The ${workspaceFolder} variable should be expanded to the absolute path of the workspace root, allowing the extension to locate the configured virtual environment.
Actual Behavior
The extension fails to find the interpreter. Logs indicate it is looking for a directory literally named ${workspaceFolder} on the file system.
Logs
File: .../ms-python.vscode-python-envs/Python Environments.log
Relevant error entries showing the literal string interpretation:
[error] Failed to execute Python to resolve info "${workspaceFolder}/backend/.venv/bin/python": No such file or directory
[warning] Unknown Python Env "${workspaceFolder}/backend/.venv/bin/python"
[error] Error resolving default interpreter: Failed to resolve env "${workspaceFolder}/backend/.venv/bin/python"
Environment
- OS: macOS
- VS Code version: 1.109.3
- Python Extension version: 2026.0.0
- Python Environments Extension version: 1.16.0
Additional Context
- Using an absolute path (e.g.,
/Users/username/project/.venv/bin/python) works correctly as a workaround.