microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
159.32k stars 27.87k forks source link

previously declared env variables are never updated #212606

Closed cellulosa closed 1 week ago

cellulosa commented 2 weeks ago

Does this issue occur when all extensions are disabled?: Yes

Steps to Reproduce:

  1. define some env variables into an .env file
  2. launch docker compose up, then stop it
  3. change variable value in .env file
  4. relaunch docker compose up
  5. The variable value is still the old one. I need to run unset VARIABLE_NAME to be able to give it a fresh new value
roblourens commented 2 weeks ago

Is this a problem with the Remote-Containers extension? Or the Docker extension? I'm not following the vscode connection

cellulosa commented 2 weeks ago

I seems related to visual studio code, because I face the same issue when running other commands e.g. npm run dev

If I have an .env file and change the value of the variable, the new value does not seem to get picked up - unless I run unset. If I run the same command on a terminal (not in the visual studio code one), it works as expected.

roblourens commented 2 weeks ago

But isn't it docker and node that are supposed to find and read the .env file? Or is the vscode terminal involved in this feature somehow?

cellulosa commented 2 weeks ago

That's a good reflection, however the oddity is that if I run the exact same command on a normal terminal, it works fine. It is only the integrated vs code terminal that seem to be affected by this

meganrogge commented 1 week ago

You'll need to create a new terminal to see the environment changes.

cellulosa commented 1 week ago

I did. Also restarting vscode didn't help