Support command variables in a terminal profile's env property
#173,134 opened on Jan 18, 2023
Description
Behavior
I am trying to create a Python integrated terminal profile for VSCode. This integrated terminal should always use the currently selected Python Interpreter. There does not seem to be a way to do that.
Expected vs. Actual
I expect to be able to create an integrated terminal profile that uses the currently selected Python interpreter as part or all of its path.
When creating a custom terminal profile, setting the path to python works, but it does not use the correct Interpreter.
According to the VSCode documentation the path, args, and env properties of the integrated terminal configuration all support resolving variables.
https://code.visualstudio.com/docs/terminal/profiles#_configuring-profiles
Therefore, setting the terminal profile path to ${command:python.interpreterPath} should work. It does not work. The profile will not even show up in the list as a valid choice.
Steps to reproduce:
- Make a new Python project in VScode that uses a non-default Python interpreter such as in a virtualenv.
- Use the
Python: Select Interpretercommand to select the interpreter. - Create a .vscode directory in the project.
- Create a settings.json file in the .vscode directory
- Add the following custom integrated terminal profiles to the settings.json.
{
"terminal.integrated.profiles.linux": {
"pythona": {
"path": "python"
},
"pythonb": {
"path": "${command:python.interpreterPath}"
}
}
}
- Attempt to open new integrated terminals using these profiles.
- The first profile will work, but it will use the wrong Python interpreter.
- The second profile will not work at all.
# Diagnostic data
- Python version (& distribution if applicable, e.g. Anaconda): 3.8.16
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Poetry
- Value of the `python.languageServer` setting: Default