microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.25k stars 1.15k forks source link

`=` and all following contents discarded from `.env` environment variables #23078

Closed DanielRosenwasser closed 3 months ago

DanielRosenwasser commented 3 months ago

It appears that the contents of variables loaded from .env (or envFile) are incorrectly set if they contain an = within the value.

To repro this, add the following .env file to the top level of a workspace.

OOPS="WHAT=THE"
SOME_ENV_VARIABLE=https://example.com?api-version=2024-02-15-preview

Then create a new terminal and run the following commands

echo $OOPS
echo $SOME_ENV_VARIABLE

Current Behavior

WHAT
https://example.com?api-version

Expected Behavior

WHAT=THE
https://example.com?api-version=2024-02-15-preview
DanielRosenwasser commented 3 months ago

Compounded with the behavior of dotenv described at https://github.com/microsoft/vscode-python/issues/22982, this causes all sorts of unexpected behavior. I couldn't tell where my environment variables were being set within a Codespace and was banging my head against this before I opened up https://github.com/microsoft/TypeChat/pull/211.

karrtikr commented 3 months ago

This is actually an issue on VS Code: https://github.com/microsoft/vscode/issues/197603, closing as duplicate. We encourage you interact with that issue to raise priority.

DanielRosenwasser commented 3 months ago

With https://github.com/microsoft/vscode/pull/207889, this will be fixed in the March 2024 release of VS Code.

karrtikr commented 3 months ago

Thanks!