I'm using .env in a Python project, with python-dotenv, but it seems like VSCode automatically loads the environment variables from the .env.
Unfortunately, VSCode does not seem to update the environment variables when I modify the .env file, causing the Python program to run on old environment vars.
Restarting VSCode / opening new integrated terminals does not seem to help. It looks as if it caches the .env somewhere, and reloads it from cache, without removing the cache when the original file is updated.
Output of /usr/bin/env together with .env file:
Output of Help: About:
Version: 1.84.0-insider (Universal)
Commit: f1c3b1dcf85e3b6ddb24b7dce0e4b122e8ce6233
Date: 2023-10-17T05:38:23.658Z
Electron: 25.8.4
ElectronBuildId: 24154031
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Darwin x64 22.6.0
Python extension version v2023.19.12931008
.
Help: About
command (run in the command palette) into your question post. Also add the version number of your Python extension. Then add an exact procedure that can be used to reproduce the problem. – OlindaolindeHelp > Report Issue
in the menu bar. If you do, please ping me here with a link to your issue ticket and put as much detail as you can into your issue ticket. – Olindaolinde>Show Environment Contributions
. Then you can see your problematic env vars and what modifies them. In my case it wasms-python.python
. Turned out it had some experiments messing with ENV. I disabled experiments insettings.json
with"python.experiments.optOutFrom": ["All"]
and this was it. – Weiser