Repository navigation
Fix variable interpolation in .env files loaded through envFile - #14828
Open
Abdelhadi Salmaoui (abdelhadi703) wants to merge 1 commit into
Open
Abdelhadi Salmaoui (abdelhadi703) wants to merge 1 commit into
Abdelhadi Salmaoui (abdelhadi703) wants to merge 1 commit into
Conversation
Abdelhadi Salmaoui (abdelhadi703)
requested a review
from a team
as a code owner
October 10, 2026 12:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
.envfiles are supposed to support variable interpolation, but when such a file isloaded through
envFile, the values keep their${...}references and the variable isnever substituted.
With a file like
EMAILcame out as the literal${USER}@example.org. Later, when the debugconfiguration gets expanded,
${USER}is looked up as alaunch.jsonvariable, isn'tfound, and prints "Invalid variable reference ${USER} in string". The env var that was
meant to land in the debuggee doesn't.
I made
ParsedEnvironmentFileresolve${VAR}while it parses each line, against thevariables already read from the file plus the process environment. That's the behaviour
the dotenv format describes. A reference to a name we don't know is left untouched, so
${workspaceFolder}and the other launch.json variables keep working exactly as before.Three tests were added to the existing
ParsedEnvironmentFilesuite: a reference to avariable defined earlier in the same file, a reference coming from the initial
environment, and an unknown reference staying literal.
Testing: ran the
ParsedEnvironmentFilesuite with the repo's pinned@types/nodeandmocha(installed from the public registry, since the Extension.npmrcpoints at theprivate feed). 10 passing with this change. On current main the two interpolation tests
fail with
${USER}@example.orgwhereadmin@example.orgis expected, and the 7 existingtests pass either way.
Fixes #13781.