Repository navigation
Merge env keys that differ only in case on Windows - #1160
Open
Arnab Chatterjee (ArnabOPP) wants to merge 2 commits into
Open
Arnab Chatterjee (ArnabOPP) wants to merge 2 commits into
Arnab Chatterjee (ArnabOPP) wants to merge 2 commits into
Conversation
On Windows the debug env can end up with both "Path" and "PATH", which debugpy rejects with 'Found duplicate in "env": PATH'. Normalize such keys before handing the configuration to the debug adapter, merging the distinct PATH entries. Refs microsoft#261 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Author
|
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Windows environment merging can discard explicit launch values and place system PATH entries before launch-configured directories, violating source precedence and potentially selecting the wrong executable.
2 open issues
What changed in this PR
This PR targets debugpy’s duplicate environment-key rejection on Windows (#261) by normalizing the environment passed to debug launches.
Changes:
- Merges case variants of
PATH, removing duplicate directory entries. - Keeps the last value for other case-colliding keys on Windows; leaves other platforms unchanged.
- Adds unit tests for PATH merging, last-value behavior, and non-Windows handling.
| File | Description |
|---|---|
src/test/unittest/configuration/resolvers/helper.unit.test.ts |
Adds focused environment-normalization tests. |
src/extension/debugger/configuration/resolvers/helper.ts |
Adds Windows key normalization and applies it to the completed debug environment. |
Review effort: Balanced
| } | ||
|
|
||
| return env; | ||
| return normalizeEnvironmentVariableCase(env); |
| const current = env[key]; | ||
| let merged = current; | ||
| if (upper === 'PATH' && typeof previous === 'string' && typeof current === 'string') { | ||
| const entries = [...previous.split(';'), ...current.split(';')].filter( |
Address review feedback: instead of collapsing case-colliding keys at the end, canonicalize each env source (launch env, env file) first and make mergeVariables case-insensitive on Windows. This keeps launch > env file > system precedence for ordinary variables, and keeps user-supplied PATH entries ahead of the system PATH. Adds getDebugEnvironmentVariables regression tests for both cases. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Author
|
Thanks for the review. Both points are addressed in 77e0b0f:
Added |
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.


Refs #261
On Windows the debug
envcan end up containing bothPathandPATH(the code appends toPath, while an incomingenvmay already carryPATH). debugpy treats Windows env names as case-insensitive and rejects this withFound duplicate in "env": PATH.This adds
normalizeEnvironmentVariableCaseand applies it at the end ofgetDebugEnvironmentVariables. On Windows only:Path/PATHare merged into a singlePathentry, with duplicate directories removed.Other platforms are unchanged.
Notes:
Pathentries, reboot), so this may not cover every case.helper.unit.test.ts. Typecheck and lint pass. I couldn't run the full mocha suite locally (the VS Code test host fails on a path containing spaces), so I'm relying on CI for that.🤖 Generated with Claude Code