Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use environment variables in vscode settings json

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 the java.home setting.

I have tried using ${env:HOME} but this doesn't seem to work. I suspect this is only for vscode tasks.

{
    "java.home": "${env:HOME}/.sdkman/candidates/java/8.0.222.hs-adpt/"
}

Get the following error message at the moment:

The java.home variable defined in VS Code settings points to a missing or inaccessible folder (${env:HOME}/.sdkman/candidates/java/8.0.222.hs-adpt/)

like image 420
jjmark15 Avatar asked Dec 18 '25 17:12

jjmark15


1 Answers

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/"
}
like image 61
Hechi Avatar answered Dec 21 '25 09:12

Hechi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!