Open anthonykim1 opened 2 months ago
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?
vscode-python
).env
files have enough other alternative options that they do not need this from this extension.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
Maybe, for situations where it is not viable to change/edit code to introduce python-dotenv
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 https://github.com/fastapi/fastapi/issues/4251 led me to https://github.com/microsoft/vscode-python/issues/23280#issuecomment-2083078678 .
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!
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
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.
https://github.com/microsoft/vscode-python/issues/23280#issuecomment-2083078678 and https://github.com/microsoft/vscode-python/issues/23856
We should have better documentation regarding .env file.