Reference an environment variable inside the settings.json

可紊 提交于 2020-06-01 05:37:07

问题


Following this question, I want to use the environment variables to establish a cross-platform settings.json finding the right executables symlinks in the local .venv Python virtual environment.

I presume I can define environment variables on different shells by:

  • *nix
    • bash/ksh: export <varName>=<varValue> (e.g., macOS bash)
    • csh/tcsh: setenv variable value (refrence)
  • Windows:
    • cmd: set <varName>=<varValue>
    • PowerShell: $env:<varName>=<varValue>

Now according to this documentation, one should be able to use the ${env:<varName>} to reference an environment variable.

On macOS, I defined

export BIN=bin

and in the .vscode/settings.json I added:

{
    // ...
    "python.pythonPath": ".venv\\${env:BIN}\\python",
    // ...
}

but it doesn't work!

I would appreciate it if you could help me know how I can define environment variables on different platforms and reference them in the project-specific local settings.json?

来源:https://stackoverflow.com/questions/61977416/reference-an-environment-variable-inside-the-settings-json

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!