Fix: Add env object syntax to launch.json schema for cppdbg and cppvsdbg - #14691
Fix: Add env object syntax to launch.json schema for cppdbg and cppvsdbg#14691Prashant Kumar Rai (8prashant) wants to merge 28 commits into
env object syntax to launch.json schema for cppdbg and cppvsdbg#14691Conversation
|
I don't think we should have two properties that do the same thing (also, this PR does not update the optionsSchema.json which means the next time package.json is generated, this will be deleted). Adding Andrew Wang (@WardenGnaw) for comment. |
|
Thanks for the contribution. This change will work for One issue with this change is that Aside from updating the OptionsSchema.json. There needs to be a change to MIEngine to support this or limit the new schema entry to The other option is to add a cpptools configuration-provider conversion from |
|
Thanks Andrew Wang (WardenGnaw) for the review. I’ve pushed updates to address this by fixing the no-debug path so the inline adapter now merges both environment and env with env taking precedence, adding cppdbg normalization in the configuration provider to convert env to environment so MIEngine receives the format it currently supports, updating OptionsSchema.json so the new env schema entries are preserved during regeneration, and adding Run Without Debugging integration coverage to verify env is applied and correctly overrides duplicate environment entries. I intentionally kept this fix in cpptools rather than making MIEngine changes in this PR because it resolves both normal launch and Run Without Debugging immediately, whereas a MIEngine-only change would not cover no-debug, and this approach avoids cross-repo dependency and release-coordination risk while keeping the change scoped and low risk; native MIEngine env support can still be added later as a separate follow-up enhancement. |
|
Hi Sean McManus (@sean-mcmanus) |
|
Prashant Kumar Rai (@8prashant) Yeah, sorry, I've been busy with other stuff and forgot about these PRs. |
Sean McManus (sean-mcmanus)
left a comment
There was a problem hiding this comment.
Reviewed the current head; see the inline comments.
…nce integration tests for env object handling in cppdbg
…nce integration tests for env object handling in cppdbg
…rashant/vscode-cpptools into fix/12537-env-property-schema
…rashant/vscode-cpptools into fix/12537-env-property-schema
…rashant/vscode-cpptools into fix/12537-env-property-schema
There was a problem hiding this comment.
🟡 Changes recommended
Environment-driven terminal replacement can terminate an overlapping no-debug session.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 8/8 changed files
- Comments generated: 1
- Review effort level: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
Nullable adapter-facing values and unsafe reuse of unmonitored active terminals remain unresolved.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
Extension/src/Debugger/ParsedEnvironmentFile.ts:14
Environmentis the adapter-facing type used byParsedEnvironmentFile, and nullable values are not supported by either launch schema;resolveEnvObjectalso deliberately retains only strings. Widening this exported type lets aninitialEnvnull pass unchanged throughCreateFromContentandresolveEnvFileinto a normal debug adapter, reintroducing the unsupported-null path. Keep this type string-only; the inline no-debug adapter already has its separate nullable terminal-environment type.
- Files reviewed: 8/8 changed files
- Comments generated: 1
- Review effort level: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
Windows case-insensitive environment names are not merged reliably, potentially defeating env precedence.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
Extension/src/Debugger/configurationProvider.ts:732
- On Windows, environment-variable names are case-insensitive, but this merge is case-sensitive. For example,
environment: [{ "name": "PATH", ... }]plusenv: { "Path": "..." }produces two entries instead of applying the documentedenvprecedence, leaving the adapter/OS to resolve conflicting values. Normalize lookup keys on Windows while retaining the winning entry's spelling.
- Files reviewed: 8/8 changed files
- Comments generated: 0 new
- Review effort level: Balanced
…vironment objects and ensure proper merging with precedence in tests
There was a problem hiding this comment.
🟡 Changes recommended
Terminal lifecycle, macOS external-terminal propagation, and remote-target case sensitivity have unresolved correctness issues.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (2)
Previously missed (2) — in code that hasn't changed since the last review.
Extension/src/Debugger/runWithoutDebuggingAdapter.ts:106
- The computed environment does not reach a no-debug target launched in a macOS external terminal. The downstream macOS branch passes
envonly toosascript, whileTerminal do scriptexecutes the command in Terminal.app's shell, which does not inherit theosascriptprocess environment. Consequently both the newly supportedenvvalues and legacyenvironmentvalues are ignored forexternalTerminalon macOS. Please transport the overrides into the executed command safely, or fall back to the regular adapter for this configuration.
Extension/src/Debugger/runWithoutDebuggingAdapter.ts:143 activeTerminalsis populated for every integrated terminal, but it is cleared on termination only whenreleaseTerminalOnTerminateis true. That flag is set only when shell integration exists; the fallback at lines 165-173 emitsterminatedwithout releasing the marker. On shells without integration, every later run of the same program therefore treats the previous idle terminal as permanently active and creates another terminal, so repeated runs accumulate terminals instead of reusing one. Please define a fallback lifecycle that releases or removes this managed terminal once the session ends.
- Files reviewed: 8/8 changed files
- Comments generated: 1
- Review effort level: Balanced
…argets in DebugConfigurationProvider
There was a problem hiding this comment.
🔵 Needs a closer look
Terminal reuse regresses without shell integration, and macOS external terminals do not receive the configured environment.
Review details
Suppressed comments (2)
Previously missed (2) — in code that hasn't changed since the last review.
Extension/src/Debugger/runWithoutDebuggingAdapter.ts:106
- For
cppdbgRun Without Debugging withexternalConsoleon macOS, these merged values still do not reach the target.launchExternalTerminalpassesenvonly toosascript; the shell that runs the command is created by Terminal.app via AppleScript and does not inherit theosascriptprocess environment. Include the environment changes in the command sent to Terminal.app (with shell-safe escaping), or launch the external terminal through an API that propagates the environment.
Extension/src/Debugger/runWithoutDebuggingAdapter.ts:151 activeTerminalsis populated for every integrated launch, butreleaseTerminalOnTerminateis enabled only when shell integration exists. In the fallbacksendTextbranch,sendEvent('terminated')therefore never removes this terminal from the active set, so every later run of the same program creates another terminal instead of reusing the existing one. Mark the terminal releasable for the fallback path as well (or explicitly remove it before sendingterminated).
- Files reviewed: 8/8 changed files
- Comments generated: 0 new
- Review effort level: Balanced
…t variables and improving command execution
There was a problem hiding this comment.
🔵 Needs a closer look
Terminals without shell integration can be reused while their previous command is still running.
Review details
Suppressed comments (1)
Extension/src/Debugger/runWithoutDebuggingAdapter.ts:170
- In the no-shell-integration fallback,
sendTextonly queues the command, so removing the terminal fromactiveTerminalsimmediately makes it appear reusable while the launched process may still be running. A subsequent launch can then interleave another command in that shell, or dispose the terminal at line 132 when its environment differs, terminating the first process. Since completion cannot be observed on this path, stop managing this terminal for reuse so the next launch creates a separate terminal.
activeTerminals.delete(this.terminal);
- Files reviewed: 8/8 changed files
- Comments generated: 0 new
- Review effort level: Balanced
…nals upon termination
There was a problem hiding this comment.
🔵 Needs a closer look
The new macOS external-terminal environment handling lacks automated coverage.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
Extension/src/Debugger/runWithoutDebuggingAdapter.ts:209
- The macOS external-terminal environment path has no automated coverage: the new env integration test always selects an integrated/internal console, and
.github/workflows/job-compile-and-test.yml:143runs this scenario withskipExternalConsole. Please add coverage for this/usr/bin/envcommand construction, especially values requiring shell/AppleScript escaping, so regressions in external launches are caught.
- Files reviewed: 8/8 changed files
- Comments generated: 0 new
- Review effort level: Balanced
…rminal command construction
|
Hi Sean McManus (@sean-mcmanus) , Could you please re-review when you have a chance? |
Problem
#12537 : Using the shorthand
envobject syntax inlaunch.jsonproduces a false validation warning: