Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how .env files work #544

Closed
brettcannon opened this issue Jan 8, 2018 · 10 comments
Closed

Document how .env files work #544

brettcannon opened this issue Jan 8, 2018 · 10 comments
Assignees
Labels
feature-request Request for new features or functionality
Milestone

Comments

@brettcannon
Copy link
Member

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 .

@brettcannon brettcannon added feature-request Request for new features or functionality awaiting 2-PR labels Jan 8, 2018
@brettcannon
Copy link
Member Author

@DonJayamanne Is it just a file named .env? And is it just every line formatted at var=val? Comments allowed somehow or anything else that one needs to know to document this?

@DonJayamanne
Copy link

  • 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 the launch.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).

@brettcannon
Copy link
Member Author

So if python.envFile is required to be set for this to work, what is the default file name of .env from? Is there a command to create it or something?

@DonJayamanne
Copy link

DonJayamanne commented Jan 16, 2018

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.json for python.envFile.
I.e. even if the user doesn't provide this, the default is ${workspaceFolder}/.env

Is there a command to create it or something?

No. Currently we expect the user to create a file maually (named .env or other and configure the settings accordingly).

@brettcannon
Copy link
Member Author

OK, so python.envFile isn't directly required because we provide a default value.

@DonJayamanne
Copy link

OK, so python.envFile isn't directly required because we provide a default value.

Yes

@monkeez
Copy link

monkeez commented Feb 26, 2018

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?

@DonJayamanne
Copy link

@monkeez
No this wouldn't.

@barakbd
Copy link

barakbd commented Apr 10, 2018

I have a multi-line variable (encrypted private key). How can I get around this issue?

@DonJayamanne
Copy link

@barakbd please create a separate issue for this (so it can be tracked). Currently its not supported, but should be easy to fix.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

4 participants