17

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/)

5
  • try just "~/.sdkman/candidates/java/8.0.222.hs-adpt/" Commented Sep 15, 2019 at 18:39
  • Unfortunately Tilda isn't recognised either Commented Sep 15, 2019 at 19:03
  • :( would think that would work. Seeing issues: github.com/microsoft/vscode/issues/2809 env vars prob not supported yet (3+yr since issue opened) :( Commented Sep 15, 2019 at 19:09
  • Sad times, thanks for the thought though Commented Sep 15, 2019 at 19:10
  • 1
    It works for certain extensions if the author has coded the extension to handle the environment variables. Commented Jan 27, 2023 at 19:08

1 Answer 1

9

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/"
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.