Skip to content

Fix: Add env object syntax to launch.json schema for cppdbg and cppvsdbg - #14691

Open
Prashant Kumar Rai (8prashant) wants to merge 3 commits into
microsoft:mainfrom
8prashant:fix/12537-env-property-schema
Open

Fix: Add env object syntax to launch.json schema for cppdbg and cppvsdbg#14691
Prashant Kumar Rai (8prashant) wants to merge 3 commits into
microsoft:mainfrom
8prashant:fix/12537-env-property-schema

Conversation

@8prashant

Copy link
Copy Markdown

Problem

#12537 : Using the shorthand env object syntax in launch.json produces a false validation warning:

Property env is not allowed.

"env": {
    "PATH": "/usr/local/bin"
}

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds schema support for shorthand env objects in C++ launch configurations, addressing issue #12537.

Changes:

  • Adds env schemas for cppdbg and cppvsdbg.
  • Adds localized documentation for the syntax.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Extension/package.json Defines shorthand env objects.
Extension/package.nls.json Documents the new schema property.
Suppressed comments (1)

Extension/package.json:6059

  • The newly validated env form is silently ignored when this cppvsdbg configuration is started with Run Without Debugging. debugAdapterDescriptorFactory.ts:59-61 selects the inline adapter for these launch configurations, while runWithoutDebuggingAdapter.ts:62-80 reads only environment. Please merge config.env into the process environment (and cover that path in the existing no-debug tests), or treat env as unsupported so the normal adapter is used.
                            "env": {
                                "type": "object",
                                "description": "%c_cpp.debuggers.env.description%",

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Extension/package.json
@bobbrow

Copy link
Copy Markdown
Member

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.

@WardenGnaw

Copy link
Copy Markdown
Member

Thanks for the contribution. This change will work for cppvsdbg because it can also deserialize env and env has higher precedence than environment.

One issue with this change is that cppdbg does not currently support it. MIEngine only reads the environment array.

Aside from updating the OptionsSchema.json. There needs to be a change to MIEngine to support this or limit the new schema entry to cppvsdbg.

The other option is to add a cpptools configuration-provider conversion from env to environment but that adds an additional layer of transforms / errors that can happen when p;umbling the environment variables to the target process.

@8prashant

Copy link
Copy Markdown
Author

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.

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

Labels

None yet

Projects

Status: Pull Request

Development

Successfully merging this pull request may close these issues.

5 participants