vscode-go icon indicating copy to clipboard operation
vscode-go copied to clipboard

Environment Variable interpolation in settings.json

Open hrobertson opened this issue 3 years ago • 3 comments

Describe the problem VSCode does not resolve env vars in settings.json - this is left for extensions to implement themselves. For example, in the following ${env:BAR} will not be replaced:

# .vscode/settings.json
{
"go.testEnvVars": {
  "FOOBAR": "foo ${env:BAR}"
 },
}

Describe the solution you'd like Strings of the form ${env:FOOBAR} should be replaced with the environment variable value.

Describe alternatives you've considered You'd think this should be implemented in VSCode but that's not going to happen. See https://github.com/microsoft/vscode/issues/2809 and https://github.com/microsoft/vscode/pull/148514

I'm happy to contribute if there is agreement that this should be added.

hrobertson avatar Aug 05 '22 19:08 hrobertson

Hi, thanks for this issue. IIRC, variable interpolation in settings.json is a bit hacky / ad-hoc (see for example https://github.com/golang/vscode-go/issues/2310#issuecomment-1176284842, and the change resolving that issue).

This does seem like a useful feature, but I am hesitant to accept a contribution here until we've discussed on the team (there may be gnarly history I'm not aware of).

I'll bring this up in our weekly triage meeting.

findleyr avatar Aug 08 '22 15:08 findleyr

Ok, we discussed this in the team meeting, and unfortunately would like to put this on the back-burner for now. The reason is that the current handling for variable interpolation is somewhat unprincipled and inconsistent, and we are hesitant to add yet another interpolation feature right now.

CC @hyangah

findleyr avatar Aug 11 '22 17:08 findleyr

Ok. That's disappointing but thanks for the explanation. :+1:

hrobertson avatar Aug 11 '22 19:08 hrobertson