Microsoft/vscode

Support command variables in a terminal profile's env property

Open

#173.134 aberto em 18 de jan. de 2023

Ver no GitHub
 (8 comments) (0 reactions) (1 assignee)TypeScript (10.221 forks)batch import
feature-requesthelp wantedterminal-profiles

Métricas do repositório

Stars
 (74.848 stars)
Métricas de merge de PR
 (Mesclagem média 11h 43m) (1.000 fundiu PRs em 30d)

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:

  1. Make a new Python project in VScode that uses a non-default Python interpreter such as in a virtualenv.
  2. Use the Python: Select Interpreter command to select the interpreter.
  3. Create a .vscode directory in the project.
  4. Create a settings.json file in the .vscode directory
  5. Add the following custom integrated terminal profiles to the settings.json.
{
	"terminal.integrated.profiles.linux": {
		"pythona": {
			"path": "python"
		},
		"pythonb": {
			"path": "${command:python.interpreterPath}"
		}
	}
}
  1. Attempt to open new integrated terminals using these profiles.
  2. The first profile will work, but it will use the wrong Python interpreter.
  3. 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

Guia do colaborador