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

Better documentation about .env file #24034

Open
anthonykim1 opened this issue Sep 3, 2024 · 7 comments
Open

Better documentation about .env file #24034

anthonykim1 opened this issue Sep 3, 2024 · 7 comments
Labels
debt Covers everything internal: CI, testing, refactoring of the codebase, etc. needs PR Ready to be worked on

Comments

@anthonykim1
Copy link

#23280 (comment)
and
#23856

We should have better documentation regarding .env file.

@anthonykim1 anthonykim1 added the debt Covers everything internal: CI, testing, refactoring of the codebase, etc. label Sep 3, 2024
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Sep 3, 2024
@karthiknadig karthiknadig added needs PR Ready to be worked on and removed triage-needed Needs assignment to the proper sub-team labels Sep 3, 2024
@benglewis
Copy link

benglewis commented Sep 5, 2024

Honestly, I hate to be a hater and complain, but the Python: Env File option should be off-by-default, at the very least until it is "fixed". What do I mean?

  1. The implementation appeared out of nowhere one day (both myself and another developer on my team had our setup broken one day because of it, and it took me getting mad and searching all of my system packages, shell plugins and configuration and then VSCode extensions one-by-one until I realized that it was vscode-python)
  2. The implementation is not consistent with the python-dotenv package that users are used to using out there in multiple ways:
  1. When the implementation is inconsistent, it can break developers' workflows since it sets a value on the environment variable which will then not be overridden.
  2. Users that use .env files have enough other alternative options that they do not need this from this extension.

@anthonykim1
Copy link
Author

anthonykim1 commented Sep 17, 2024

Thanks for the feedback there @benglewis
Would you find https://code.visualstudio.com/docs/python/environments#_environment-variables to be helpful at all? Curious to hear what you think. -Thanks

@benglewis
Copy link

Maybe, for situations where it is not viable to change/edit code to introduce python-dotenv

@shughes-uk
Copy link

This feature cost me hours. We have an app that uses python-dotenv to load settings from a .env file. I wanted to change a setting, so just updated my env file. Normally executing the app should immediately reflect these changes, but now it was using the old value as python-dotenv gives priority to environment variables over the file.

So spend forever trying to track down where the hell the old value was coming from. Eventually fastapi/fastapi#4251 led me to #23280 (comment) .

Especially annoying as when I tried to use the vscode debugger to figure it out, of course the issue did not exist (as it was reloading the .env file each launch).

The other issues are closed, but I would beg you to reconsider having this on by default without any indication it happens unless you read the entire extension documentation. At least add a little "loaded .env variables" or something at the start of a terminal boot as a hint!

@benglewis
Copy link

Just to clarify @anthonykim1 , my feedback suggesting that it might be useful was regarding allowing a user to actively choose to turn it on and "opt-in". It should 100% definitely not be the default. Additionally, a notification when opening a shell that the .env was loaded into environment variables with a link to the setting, would probably help people that are stuck after having enabled it by mistake

@legau
Copy link

legau commented Oct 9, 2024

To add to this, in non-Python projects, activating one time a Python interpreter causes all subsequent terminal sessions to load these old state values with no way (to my knowledge) to remove them except uninstalling the extension. In a non-python project the interpreter will almost never come up automatically to refresh the values except by hand.
This is absolutely unexpected behavior even with comprehensive documentation available.
There are a lot of issues about this and everyone states the long time it has taken them to debug such weird behavior.

@mkp-bangemann
Copy link

My current workaround is disabling the Python extension for non-Python projects in that workspace. Prior to finding the cause, I just used an external terminal as a workaround. But it definitely caused a few headaches every now and then trying to find the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debt Covers everything internal: CI, testing, refactoring of the codebase, etc. needs PR Ready to be worked on
Projects
None yet
Development

No branches or pull requests

6 participants