问题
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)
- bash/ksh:
- Windows:
- cmd:
set <varName>=<varValue>
- PowerShell:
$env:<varName>=<varValue>
- cmd:
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