Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Substitute variables in launch configuration keys (and not only in values) #34059

Closed
nbstar opened this issue Sep 9, 2017 · 6 comments
Closed
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality release-notes Release notes issues verified Verification succeeded
Milestone

Comments

@nbstar
Copy link

nbstar commented Sep 9, 2017

  • VSCode Version: 1.15.1
  • OS Version: Win7

Feature description:
It would be nice to use the environment variable $ {env: variable} in launch.json sourceFileMap, like using the built-in variable $ {workspaceRoot}.

The present situation is that we can write $ {env: variable} in sourceFileMap, but it is not replaced by real path like $ {workspaceRoot}.

So, when debugging with cpptools extension for c++ program,vscode pops up the following message box:

Error: Unable to open 'main.cpp': File not found (\usr1\pDTest\demo\main.cpp). Create File Cancel

The sourceFileMap is very simple:

"sourceFileMap": {
    // "remote": "local"
    
    // This way works well
    // "/usr1/pDTest/demo" : "D:\\demo"
    
    // This way does not work
    "/usr1/{env:USERNAME}/demo" : "D:\\demo"
},

This feature is useful for collaborative development of multiple programmers. we can push launch.json on git repo, and do not need everyone to modify it.

@roblourens roblourens added feature-request Request for new features or functionality debug Debug viewlet, configurations, breakpoints, adapter issues labels Sep 9, 2017
@isidorn
Copy link
Contributor

isidorn commented Sep 12, 2017

Yes, currently we are only resolving the values of objects in the configuration, not the keys (which is what you want).
We accept PRs that elegantly fix this, code pointer https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/services/configurationResolver/node/configurationResolverService.ts#L194

@isidorn isidorn removed their assignment Sep 12, 2017
@weinand weinand changed the title Feature require: sourceFileMap support environment variable like ${workspaceRoot} Substitute variables in launch configuration keys (and not only in values) Sep 29, 2017
@OkkeHendriks
Copy link

@nbstar I was wondering if you have found a workaround for this?

@weinand weinand added this to the On Deck milestone Nov 14, 2017
@weinand
Copy link
Contributor

weinand commented Nov 14, 2017

@isidorn since VS Code's use of JSONs sometimes has values on the left hand side (as keys), we should consequently support variable substitution there too (and I've targeted this for "On Deck").

I assume this feature is low-hanging fruit?

@isidorn
Copy link
Contributor

isidorn commented Nov 14, 2017

@weinand should not be too complex

@isidorn
Copy link
Contributor

isidorn commented May 11, 2018

@dbaeumer note that we now also resolve keys not only values in configuraitons since this also affects tasks.

@aeschli
Copy link
Contributor

aeschli commented May 31, 2018

Verified that variables are substituted in both values and keys:

        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceFolder}/index.js",
            "env": {
                "foo${lineNumber}": "${workspaceFolder}"
            }
        },

@aeschli aeschli added verified Verification succeeded and removed verification-needed Verification of issue is requested labels May 31, 2018
@isidorn isidorn added the release-notes Release notes issues label Jun 1, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality release-notes Release notes issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

6 participants