Change default configuration values to not load envFile #25184
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed Change
Default to not loading any
.env
file instead of checking for and loading one at the workspace root if present. This is a potential breaking change for any developers implicitly relying on the current default value of"${workspaceFolder}/.env"
.Why
vscode-python
implements it's own version of dotenv support based onhttps://github.com/motdotla/dotenv
(implementation references this in comments in multiple places).This implementation is incompatible with the
python-dotenv
library, namely thatpython-dotenv
supports multiline quoted values, butvscode-python
does not. Inline comments are also not supported byvscode-python
(see #23799).We repeatedly run into this issue at my company, where VsCode is loading incomplete strings into env vars, making it impossible for
python-dotenv
to load them correctly afterwards (sincepython-dotenv
won't overwrite already set variables to support easier overwriting for tests, etc).In general I think that it is very unexpected that the
vscode-python
extension will load.env
files using a different and incompatible implementation to the Python dotenv libraries. I think this is evidenced by various issues, such as #23575.Long term, even if there is a goal to support automatic
.env
file loading within VsCode itself, IMO it makes more sense for this to be supported in VsCode itself or via a dedicated extension. Having a custom implementation embedded in the Python extension is almost certainly wrong, and disabling this by default is almost certainly a good start to eventually being able to sunset this logic in this extension.