-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Support variables when resolving values in settings #2809
Comments
I was looking into this a little, but it'd be helpful to understand what the behavior should look like on non windows systems. Mainly, should we use the same environment variable %SYNTAX% or try to emulate the host platform? I'd argue that having VS Code be consistent across multiple systems is more important than constancy with the host platform, but I'm curious to see if anyone has any objections to that. We could use $SYNTAX or something else, across all platforms too. |
@mjbvz I thought about this when I first opened the issue but neglected to mention it because I'm indifferent. However, I do agree consistency within VS Code is likely more beneficial than with the OS. Visual Studio seems to use I guess my vote goes toward |
Related: #3759 |
Just looking through the code, this best approach seems to be using the existing Another approach may be to update |
You mean |
Yes, thanks. I've updated the comment with the correct file name. Resolving the environment variables only when they are actually needed would be best, so that always pick up the latest values. |
@DonJayamanne is starting to look into this from #8555 |
@pcgeek86, this capability hasn't been added yet. |
@DonJayamanne for your case (Python I think?), did you find a workaround to support this? If we add variables support to settings, we need to think about validation. If a setting only allows for certain string values, putting in a variable would always result in warnings. I guess this problem already exists today for launch.json and task.json. |
@bpasero, yes for Python extension i do have a work around, with support for $workspaceRoot and $env.. (env variables) in settings.json. "python.pythonPath":"${workspaceRoot}/env/bin/python" However, there's one problem. |
@bpasero , upon further analysis, I believe the bug is in configVariables. |
It's not uncommon for me to open the same folder, once inside a development container, and once on the root of my machine. The way settings are shared between the two is a benefit and a curse; being able at least to access environment variables in the same way as I can in the launch JSON would help a lot in terms of managing configs. |
I too would like to see config variables usable in settings.json and in *.code-workspace for multi-root projects. I think they should be resolved transparently in variables owned by plugins. |
+1 I personally want to use the |
+1 Wanted to substitute ${env:<some-env-var>}.
|
Probably the fact each extension can have it's own custom settings with its own format, and you can't just easily force this syntax globally, so each extension would need to be prepared to deal with it somehow, individually. Unless, of course you used something like, e.g.: "some.setting": "value is passed verbatim, including literally ${env:example}",
"some.setting$": "value substitutes ${env:example} variables generically" |
I disagree - if people use the official namespaces and variables like
That would be no problem as after a change the variables will be auto-resolved before the extension code "sees" it, so they won't resolve (commonly only partial) as before and can drop code for that later. Therefore:
|
In that case, for backward compatibility, the settings.json could define an self consumed (which by default is "true") {
"settingsJson.variableExpand.enable": "false"
"some.more.settings": "value"
} which disables the common variable expansion on settings.json level before passing to the extensions. Not exactly the most beautiful mechanism in general, but would only have be used where variable names clash. |
If extension variable names clash with any of the official namespaces and variables, the extension should break and the extention author should fix their use to be in line with the documentation. |
No. Current documentation says it's supported in "some select settings" not that it's meant to be supported in every setting. If this changes, it's VSCode that's breaking stuff, and you can't just carelessly break extensions like this. However, I do agree with the points made that most would likely transition smoothly. So I guess the best course of action would be to expect every extension to be able to support this, but to avoid compatibility breakage, it would need just a different API for the extension to get the setting.
|
Agree. This is the clean way. Suggestion was just to show a backward compat. mode/mechansim to allow a transition. |
A new API is a good solution, if the old API will be removed within a reasonable time frame, to make the transition happen. |
I disagree. For the second point: note that several extensions that weren't updated do not work since several versions because there is a compatibility break if you don't update some dependencies to newer versions, if you do that as the extension author it leads to the need to adjust the code to cater for changed ABI. For the first point: that will lead to a lot of extensions not getting the expected result (also: there are a bunch of extensions that aren't changed any more, we should not create an unneeded reason for those to not work in the future, which your adjusted ABI effectively means). Not changing the ABI is definitely better, as noted nothing will break as long as:
|
nor ${workspaceFolderBasename} nor ${workspaceRootFolderName} still being resolved in settings.json on latest vscode 1.90.1 Instead of resolved value the "${workspaceFolderBasename}" appears in the logs of any extension (in my case clangd) And for example, the ${workspaceFolder} from the same group just works. These variables have been introduced around 2019. Is this proper thread for this information or yet another issue is required for it? Version: 1.90.1 |
I would very much like to be able to utilize variables like $workspaceFolder in our workspace level settings.json to resolve paths relative to our project(s). We have developers who install projects to different paths and wish our settings to persist across users. Being able to use relative paths would be a viable alternative as well. Maybe its just some settings that require entire paths, for example I cannot get any configuration of
working, however,
works fine. As a work around we are using a powershell script executed from a task to update our .vscode/settings.json -- not ideal for many reasons. |
same here |
Almost 9 years... any chance this'll get picked up? |
I don't think so. I have been following this issue for around five years now... |
Hi,
I was just reading the latest updates and it says one can install
typescript@next
globally and then settypescript.tsdk
so VS Code can use the appropriate version/installation. In a team environment, I'd like to put that setting in our project, something like:.vscode/settings.json
:The problem is restarting VS Code results in an error:
Now the setting needs to be per-person because I highly doubt my teammates have
tsc
installed inC:\Users\Olson\AppData\Roaming\npm\node_modules\typescript\lib
😉Could we get environment variables evaluated on that and all other settings that involve paths?
I haven't tested other paths, but I see these in the Default Settings:
git.path
markdown.styles
json.schemas
typescript.tsdk
php.validate.executablePath
The text was updated successfully, but these errors were encountered: