Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting python.terminal.activateEnvironment: true results in loading env variables from the .env file #23865

Closed
lks-dev opened this issue Jul 24, 2024 · 1 comment
Labels
bug Issue identified by VS Code Team member as probable bug documentation triage-needed Needs assignment to the proper sub-team

Comments

@lks-dev
Copy link

lks-dev commented Jul 24, 2024

The expected behavior, as stated by the online docs, is that the terminal is not influenced by the contents of the python.envFile:

An environment variable definitions file is a text file containing key-value pairs in the form of environment_variable=value, with # used for comments. Multiline values aren't supported, but references to previously defined environment variables are allowed. Environment variable definitions files can be used for scenarios such as debugging and tool execution (including linters, formatters, IntelliSense, and testing tools), but aren't applied to the terminal.

The documentation of the python.terminal.activateEnvironment setting, also does not reference the .env file as part of the activation:

Indicates whether to automatically activate the environment you select using the Python: Select Interpreter command when a new terminal is created.
For example, when this setting is true, and you select a virtual environment, the extension automatically runs the environment's activate command when creating a new terminal (source env/bin/activate on macOS/Linux; env\scripts\activate on Windows).

However, when using an .env file in conjunction with the python.terminal.activateEnvironment setting, the contents of the .env file are applied to the terminal, which is, to my knowledge, not explicitly documented, but probably should be?


The behavior was replicated by me on Linux (bash) and windows (cmd) with pip .venvs and vscode-python v2024.10.0.
Taking a look at the environment contributions shows environment variables set in the .env file, see second to last line VAR.

# Terminal Environment Changes

## Extension: vscode.git

[...]

## Extension: ms-python.python

Activated environment for `./.venv/bin/python`

- `VIRTUAL_ENV=/path/to/.venv`
- `VAR=I am defined in the issue.env file which is set as python.envFile in the vscode workspace`
- `PATH=~/.vscode/extensions/ms-python.python-2024.10.0-linux-x64/python_files/deactivate/bash:/path/to/.venv/bin:${env:PATH}`
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Jul 24, 2024
@karthiknadig karthiknadig added bug Issue identified by VS Code Team member as probable bug documentation labels Jul 24, 2024
@luabud
Copy link
Member

luabud commented Jul 26, 2024

hey @lks-dev, thanks for bringing this up! We probably need to revisit this and document the right behaviour if applicable. We'll look into this when we can!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug documentation triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

4 participants