Environment variables in Linux are supported now in VSCode (although I don't know since when or which version exactly). I have VSCode for Linux 1.73.1.

You can now use the following (just like in the question above):

{
    "java.home": "${env:HOME}/.sdkman/candidates/java/8.0.222.hs-adpt/"
}
Answer from Hechi on Stack Overflow
🌐
GitHub
github.com › microsoft › vscode › issues › 205327
Variables Support in Setting.json · Issue #205327 · microsoft/vscode
February 16, 2024 - Type: Feature Request VS Code settings in Setting.json doesn't support variables(such as ${userHome},${env:USERNAME}). It spoils the experience. Some plugins(such as Run Terminal Command) support environment variables in settings.json. V...
Author   xiaoxstz
🌐
GitHub
github.com › microsoft › vscode › issues › 114515
`${env:VARIABLE}` not work sometimes in `settings.json` · Issue #114515 · microsoft/vscode
January 18, 2021 - So why VS Code did not recognize the JAVA_HOME variable? ... In settings.json, set java.configuration.maven.userSettings to ${env:M2_HOME}\\conf\\settings.xml, and M2_HOME="D:\Program Files\maven".
Author   woobhurk
Discussions

linux - how to use environment variables in vscode settings json - Stack Overflow
I want to be able to use linux environment variables in vscode workspace settings (specifically $HOME) so that I can specify paths that aren't specific to a user. In this case I am trying to set th... More on stackoverflow.com
🌐 stackoverflow.com
Support using environment variables in settings.json
VSCode Version: 1.2.1 OS Version: Windows 10 (1511) It would be nice to be able to use environment variables in paths in settings.json, this is not possible in build 1.2.1 and older. In my scenarii... More on github.com
🌐 github.com
3
July 6, 2022
environment variables no longer valid in workspace settings.json or tasks.json
There was an error while loading. Please reload this page · Does this issue occur when all extensions are disabled?: Yes More on github.com
🌐 github.com
12
April 4, 2019
my settings.json file can't read variables in my .env file.
I am trying to override the default python interpreter for a specific workspace. I have created a .vscode directory in the folder with the following two files: .vscode/settings.json: { "python... More on github.com
🌐 github.com
1
January 31, 2023
🌐
GitHub
github.com › golang › vscode-go › issues › 2395
Environment Variable interpolation in settings.json · Issue #2395 · golang/vscode-go
August 5, 2022 - # .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.
Author   hrobertson
🌐
GitHub
github.com › microsoft › vscode › issues › 8147
Support using environment variables in settings.json · Issue #8147 · microsoft/vscode
July 6, 2022 - It would be nice to be able to use environment variables in paths in settings.json, this is not possible in build 1.2.1 and older. In my scenariio I`m syncing VS Code settings between computers, for example: // Specifies the path to a PowerShell Script Analyzer settings file. Use either an absolute path (to override the default settings for all projects) or use a path relative to your workspace. "powershell.scriptAnalysis.settingsPath": "%home%.vscode\PSScriptAnalyzerSettings.psd1"
Author   janegilring
🌐
GitHub
github.com › Microsoft › vscode › issues › 43351
Possible to support variables in settings.json? · Issue #43351 · microsoft/vscode
Maven stores downloaded JARs to ~/.m2. On Linux ~ expands to /home/username, while on MacOS it expands to /Users/user.name. Now if I could use an environment variable in the settings.json file, I could keep the setting platform agnostic in the form of ${env:HOME}/.m2/path/to/lombok.jar
Author   ghost
🌐
Steve Kinney
stevekinney.com › courses › visual studio code › controlling settings with environment variables in visual studio code
Controlling Settings with Environment Variables in Visual Studio Code | Visual Studio Code | Steve Kinney
March 17, 2026 - You can reference environment variables in settings.json using the ${env:VARIABLE_NAME} syntax. { "terminal.integrated.defaultProfile.windows": "${env:WSL_DISTRO_NAME}", // Use WSL distro name as default terminal profile on Windows ...
Find elsewhere
🌐
GitHub
github.com › microsoft › vscode › issues › 71740
environment variables no longer valid in workspace settings.json or tasks.json · Issue #71740 · microsoft/vscode
April 4, 2019 - VSCode Version: 1.33.0 OS Version: Ubuntu 18.0.4 Steps to Reproduce: put some variables in EG: ${env:PATH} "terminal.integrated.env.linux": { "DATA": "${env:PATH};${workspaceFolder}/xtensa-esp32-elf/bin", } echo out that variable in the ...
Author   sebirdman
🌐
GitHub
github.com › microsoft › vscode-python › issues › 20599
my settings.json file can't read variables in my .env file. · Issue #20599 · microsoft/vscode-python
January 31, 2023 - I am trying to override the default python interpreter for a specific workspace. I have created a .vscode directory in the folder with the following two files: .vscode/settings.json: { "python.envFile": "${workspaceFolder}/.vscode/.env",...
Author   xxc-zsz
🌐
Visual Studio Code
code.visualstudio.com › docs › reference › variables-reference
Variables reference
November 3, 2021 - The predefined variables are supported in a select number of setting keys in settings.json files such as the terminal cwd, env, shell and shellArgs values.
🌐
Reddit
reddit.com › r/vscode › using environmental variable in settings.json
r/vscode on Reddit: Using environmental variable in settings.json
January 2, 2025 -

Could anyone tell me why this doesn't work?

{
    "roc-lang.language-server.exe": "${env:ROC_LANGUAGE_SERVER_PATH}",
    // If you'd like to format Roc files on save
    "editor.formatOnSave": true
}

This is in the workspace settings.json for a project. When I look at the plugin's output, it's treating that exact string as the path, rather than resolving it to the value of the environmental variable. A few other things to note:

  1. If I instead use the literal string that is the value of the variable, it works fine.

  2. I am able to echo that variable in vs code's terminal, so I know it's available.

  3. I am on on linux with a reasonably recent version of vs code.

Thanks.

EDIT: Maybe this is just a limitation of the roc language plugin, that it isn't programmed to resolve the variable?

🌐
Reddit
reddit.com › r/vscode › my settings.json file can't read variables in my .env file.
r/vscode on Reddit: my settings.json file can't read variables in my .env file.
January 27, 2023 -

I am trying to override the default python interpreter for a specific workspace. I have created a .vscode directory in the folder with the following two files:

settings.json:

{
    "python.envFile": "${workspaceFolder}/.vscode/.env",
    "python.defaultInterpreterPath": "${env:MY_PYTHON_PATH}/bin/python",
}

.vscode/.env:

MY_PYTHON_PATH=/path/to/my/python/interpreter

But the python interpreter is actually getting set to /bin/python - which implies that ${env:MY_PYTHON_PATH} is just empty.

Any ideas what is going wrong here?

🌐
GitHub
github.com › microsoft › vscode-dotnettools › issues › 1544
How to set environment variables in launch.json? · Issue #1544 · microsoft/vscode-dotnettools
October 17, 2024 - microsoft / vscode-dotnettools Public · Notifications · You must be signed in to change notification settings · Fork 39 · Star 287 · New issueCopy link · New issueCopy link · Closed · Closed · How to set environment variables in launch.json?#1544 · Copy link · Assignees ·
Author   lucasmsoares96
🌐
GitHub
github.com › microsoft › vscode › issues › 2809
Support variables when resolving values in settings · Issue #2809 · microsoft/vscode
February 9, 2016 - In a team environment, I'd like to put that setting in our project, something like: .vscode/settings.json: { "typescript.tsdk": "%APPDATA%/npm/node_modules/typescript/lib" } The problem is restarting VS Code results in an error: The path c:\Projects\Derp\%APPDATA%\npm\node_modules\typescript\lib doesn't point to a valid tsserver install.
Author   OlsonDev
🌐
Orchestra
getorchestra.io › guides › using-os-environ-with-local-settings-in-vs-code-settings-json
Using os.environ with Local Settings in VS Code settings.json | Orchestra
March 22, 2025 - By leveraging os.environ, you can reference environment variables from within your code or settings files, keeping your sensitive information out of reach from version control. VS Code allows developers to customize their workspace configuration through settings.json.
🌐
GitHub
github.com › anthropics › claude-code › issues › 21926
VSCode extension doesn't read env variables from ~/.claude/settings.json · Issue #21926 · anthropics/claude-code
January 30, 2026 - When launching VSCode from Dock, the extension shows the login screen instead of entering chat mode, even though ANTHROPIC_API_KEY and ANTHROPIC_BASE_URL are configured in settings.json. ... The extension should read env variables from ~/.claude/settings.json and enter chat mode directly. Setting system-level environment variables via launchctl setenv works, but this shouldn't be necessary.
Author   vincent4j
🌐
Donjayamanne
donjayamanne.github.io › pythonVSCodeDocs › docs › python-path
Python Path and Version | Python in Visual Studio Code
Unfortunately use of relative paths when configuring the interpreter in settings.json will not work with the debugger. Hence the solution is to provide the fully qualified path. This could be achieved with the use of simple variables such as the following: Where ${workspaceRoot} resolves to the current work space (project) directory. { "python.pythonPath": "${workspaceRoot}/venv/bin/python" } Similar to the use of ${workspaceRoot}, environment variables could be used in configuring the path to the python interpreter.
Top answer
1 of 5
13

Currently you cannot set variables in the settings.json file.

The current open issue for VS Code to implement this feature is here: https://github.com/microsoft/vscode/issues/2809

It has yet to have a PR and the opening of the issue occurred Feb 2016, but with comments within the last 2 months.

2 of 5
3

Quoting from the same docs which were linked in the question post (asker just needed to scroll down) https://code.visualstudio.com/docs/editor/variables-reference#_is-variable-substitution-supported-in-user-and-workspace-settings :

Is variable substitution supported in User and Workspace settings?

The predefined variables are supported in a select number of setting keys in settings.json files such as the terminal cwd, env, shell and shellArgs values. Some settings like window.title have their own variables:

"window.title": "${dirty}${activeEditorShort}${separator}${rootName}${separator}${appName}"

Refer to the comments in the Settings editor (Ctrl+,) to learn about setting specific variables.

Even quoting from the very first sentence in that entire document:

Visual Studio Code supports variable substitution in Debugging and Task configuration files as well as some select settings. Variable substitution is supported inside some key and value strings in launch.json and tasks.json files using ${variableName} syntax.

If you want to be able to use variables freely in settings.json, then see Support variables when resolving values in settings #2809, give it a thumbs up to show support for it, and subscribe to it to get notified about discussion and progress. Please avoid making comments there like "+1" / "bump" / "still not implemented??!!1?!?1".

🌐
GitHub
github.com › microsoft › vscode › issues › 95371
Allow `launch.json` configuration to access environment specified by `"envFile"` · Issue #95371 · microsoft/vscode
April 15, 2020 - # The purpose of this file is to provide an environment which can be read # by configurations in launch.json, such as remote-host socket. REMOTE_HOST_SOCKET=192.168.1.155:1234 · I should be able to create a launch config that specifies these values: { "envFile": "${workspaceFolder}/.vscode/remote_debug.env", "miDebuggerServerAddress": "${env:REMOTE_HOST_SOCKET}", } ...where this launch config reads the environment variables in remote_debug.env, and they can be referenced by other parts of the launch configuration such as miDebuggerServerAddress.
Author   jnickg