Repository navigation
Document how .env files work #544
Description
Activity
- addedfeature-requestRequest for new features or functionalityRequest for new features or functionality
on Jan 8, 2018 brettcannon commented
on Jan 12, 2018 MemberAuthorMore actionsDon Jayamanne (@DonJayamanne) Is it just a file named
.env? And is it just every line formatted atvar=val? Comments allowed somehow or anything else that one needs to know to document this?- Comments starting with
#are ignored - Multi line variables are not supported
- Basic format is
var=val - The name of the file defaults to
.env, - The name of the file is configurable in the (use/workspace) settings as follows:
"python.envFile": "${workspaceFolder}/environmentFile.txt"
- The name of the file is configurable in the debugger launch settings as follows:
"envFile": "${workspaceFolder}/environmentFile.txt",
- If the setting
envFile(listed previously) is not available in thelaunch.json(debugger settings file), then the environment file will not be loaded (i.e there are no defaults if the setting is missing from the configuration file).
- Comments starting with
brettcannon commented
on Jan 16, 2018 MemberAuthorMore actionsSo if
python.envFileis required to be set for this to work, what is the default file name of.envfrom? Is there a command to create it or something?So if python.envFile is required to be set for this to work,
Yes
what is the default file name of .env from
This default value comes from the configuration settings in
package.jsonforpython.envFile.
I.e. even if the user doesn't provide this, the default is${workspaceFolder}/.envIs there a command to create it or something?
No. Currently we expect the user to create a file maually (named
.envor other and configure the settings accordingly).brettcannon commented
on Jan 17, 2018 MemberAuthorMore actionsOK, so
python.envFileisn't directly required because we provide a default value.OK, so python.envFile isn't directly required because we provide a default value.
Yes
Can you set values in the .env file that get picked up in the python workspace settings?
Say I had an .env file with:
MY_VARIABLE=C:/some/path/Then in my workspace settings I had:
{ "python.pythonPath": "${env:MY_VARIABLE}/python" }Would this work?
Mitch Coote (@monkeez)
No this wouldn't.I have a multi-line variable (encrypted private key). How can I get around this issue?
Barak BD (@barakbd) please create a separate issue for this (so it can be tracked). Currently its not supported, but should be easy to fix.
- locked as resolved and limited conversation to collaborators
on Jul 11, 2018
Should probably cover it in https://code.visualstudio.com/docs/python/environments. Came up due to confusion found at https://stackoverflow.com/questions/48120642/visual-studio-code-python-import-paths .