Microsoft/vscode

Support command variables in a terminal profile's env property

Open

#173,134 创建于 2023年1月18日

在 GitHub 查看
 (8 评论) (0 反应) (1 负责人)TypeScript (10,221 fork)batch import
feature-requesthelp wantedterminal-profiles

仓库指标

Star
 (74,848 star)
PR 合并指标
 (平均合并 11小时 43分钟) (30 天内合并 1,000 个 PR)

描述

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

贡献者指南