Skip to content

Standardize how to do environment variable parsing & substitution #18307

Open

Description

@karrtikr

There're two parts to this issue:

Parsing

We should probably always follow dotenv syntax:

Substitution

There are currently two ways of substituting variables in a .env file:

VAR2="value;${env:VAR1}"

and

VAR2="value;${VAR1}"

and a combination of both has to used to resolve all variables in different situations. However, this is not standard syntax. Again we should probably rely on the dotenv syntax always.

Activity

  1. added
    bugIssue identified by VS Code Team member as probable bug
    metaIssue that is tracking an overall project
    triage-neededNeeds assignment to the proper sub-team
    area-environmentsFeatures relating to handling interpreter environments
    on Jan 18, 2022
  2. changed the title [-]Clarify how to do environment variable substitution[/-] [+]Standardize how to do environment variable substitution[/+] on Jan 18, 2022
  3. changed the title [-]Standardize how to do environment variable substitution[/-] [+]Standardize how to do environment variable parsing & substitution[/+] on Nov 2, 2023
  4. ababak commented on Nov 8, 2024

    @ababak

    Any updates on this? The lack of support for newlines is problematic.

  5. eleanorjboyd commented on Dec 12, 2024

    @eleanorjboyd

    Karthik Nadig (@karthiknadig) and Anthony Kim (@anthonykim1) - wondering if something along this lines should be a larger discussion across different features. I feel like I have seen a few of these regarding variable substitution and might be worthwhile to tackle?

  6. karthiknadig commented on Dec 12, 2024

    @karthiknadig
    Member

    We can do this in the new environments extension. The plan is to have an implementation there that can handle broad set of cases.

    The is still in ideation phase, and is a work in progress:
    API: https://github.com/microsoft/vscode-python-environments/blob/0519050ee0d85baf0487bdb4a7519fbc06db60bc/src/api.ts#L1197-L1222

    Implementation: https://github.com/microsoft/vscode-python-environments/blob/main/src/features/execution/envVariableManager.ts

  7. nmoreaud commented on Sep 11, 2026

    @nmoreaud

    Is there a solution to have variables substitution of type VAR_A=aaa_${SUFFIX} when debugging "python current file"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-debuggingarea-environmentsFeatures relating to handling interpreter environmentsbugIssue identified by VS Code Team member as probable bugmetaIssue that is tracking an overall projectneeds PRReady to be worked on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions