Running python tests in VSCode. I have a .env
file that is loading (I can add new vars, and see the change reflected in a print(...
of os.environ
.
However, variable expansion within that file is doing something odd. It seems to expand ${workspaceFolder}
in some cases (specifically, PYTHONPATH=
) but not others. ??
Here's my .env
file. Again, it is loading, as I can see changes if i add vars, or change the contents of the (fully working) PYTHONPATH
var:
FOOBAR1=${workspaceFolder}/foobar1.txt
PYTHONPATH=${workspaceFolder}/backend/src:/tmp/foo-2:${env:PYTHONPATH}
however print(
'ing all the os.environ
's shows:
...
?
v
FOOBAR1=/foobar1.txt
PYTHONPATH=/home/-omitted-/backend/src:/tmp/foo-2:
...
${workspaceFolder}
is expanded for one var, but not the other?? I've tried re-ordering. Don't see anything here or on google.
Help !? Thank you!
There is no variable expansion in vscode .env
files at all. Any ${workspaceFolder}
or similar variables are replaced by empty strings.
Note: Variable substitution is only supported in VS Code settings files, it will not work in .env environment files.
https://code.visualstudio.com/docs/python/environments#_environment-variable-definitions-file
Something else is probably prepending the /home/-omitted-
to PYTHONPATH
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.