-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Behaviour
Potentially related to #18650.
Expected vs. Actual
I have a multi-root workspace and I name the folders for clarity in the file explorer and search results. The ${workspaceFolder}
variable, however, doesn't seem to be resolved correctly when scoped by folder name in Python settings like python.defaultInterpreterPath
. Given the following folders definition in my .code-workspace
file:
{
"folders": [
{
"name": "named-folder",
"path": "org/projects/project-folder"
}
]
}
I expect to be able to use ${workspaceFolder:named-folder}
in python.defaultInterpreterPath
:
{
"settings": {
"python.defaultInterpreterPath": "${workspaceFolder:named-folder}/.venv/bin/python",
}
}
Instead, ${workspaceFolder:named-folder}
is not resolved at all and I'm forced to use the implicit folder name as derived from its path:
{
"settings": {
"python.defaultInterpreterPath": "${workspaceFolder:project-folder}/.venv/bin/python",
}
}
This is inconsistent with how ${workspaceFolder:<folder>}
is resolved in other places. For instance, ${workspaceFolder:project-folder}
will not resolve in a task when the folder is named like in my example above:
{
"tasks": {
"version": "2.0.0",
"tasks": [
{
"label": "echo",
"type": "shell",
"command": "echo ${workspaceFolder:project-folder}",
}
]
},
}
Variable ${workspaceFolder:project-folder} can not be resolved. No such folder 'project-folder'.
Steps to reproduce:
- Create a multi-root workspace with at least one explicitly named folder, like in my example above.
- Set the
defaultInterpreterPath
to${workspaceFolder:<explicit-folder-name>}/<relative-path-to-python-interpreter>
- Observe in the Python output that the
${workspaceFolder}
was not resolved and, thus, no interpreter is found.
- Python version (& distribution if applicable, e.g. Anaconda): 3.9.16
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Unknown
- Value of the
python.languageServer
setting: Pylance
Output for Python
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Python
)
2023-11-09 12:16:51.050 [warning] Identifier for virt-virtualenv failed to identify /Users/ome/Code/org/projects/project-folder/${workspaceFolder:named-folder}/.venv/bin/python [Error: ENOENT: no such file or directory, scandir '/Users/ome/Code/org/projects/project-folder/${workspaceFolder:named-folder}/.venv/bin'] {
errno: -2,
code: 'ENOENT',
syscall: 'scandir',
path: '/Users/ome/Code/org/projects/project-folder/${workspaceFolder:named-folder}/.venv/bin'
}