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

Allow references in .env file #3275

Closed
Flamefire opened this issue Nov 9, 2018 · 6 comments
Closed

Allow references in .env file #3275

Flamefire opened this issue Nov 9, 2018 · 6 comments
Assignees
Labels
feature-request Request for new features or functionality

Comments

@Flamefire
Copy link

Currently the .env file is not a real dot-env-file because it is a simple list of name=value pairs. However "real" .env supports string references: see https://marketplace.visualstudio.com/items?itemName=mikestead.dotenv

Why is this important?

I set up my PYTHONPATH in the .env file to mirror runtime set env variables so I can use the integrated debugger. This becomes quite lengthy so I tried:

REPO="/home/user/git/foobar"
PYTHONPATH="${REPO}/foo:${REPO}/bar"
# Or
PYTHONPATH="${REPO}/foo"
PYTHONPATH="${PYTHONPATH}:${REPO}/bar"

Would be great, if this was allowed.

@DonJayamanne DonJayamanne added feature-request Request for new features or functionality feature-* labels Nov 9, 2018
@DonJayamanne
Copy link

  • Use https://www.npmjs.com/package/dotenv-expand to expand variables
  • Ensure ${workspaceFolder} gets expanded to current workspace folder
  • Ensure we support multi-root workspace folders (all you need to do is use current resource when expanding ${workspaceFolder})

@ericsnowcurrently pointed out that ${xxx} values for env variables will get expanded in the shell (applies to Pwsh, bash, etc). I.e. when using env files in shells, then we don't need to expand them.
However when not using a shell, then we will need this.

@DonJayamanne DonJayamanne added triage-needed Needs assignment to the proper sub-team and removed triage labels Jan 31, 2019
@d3r3kk d3r3kk added the triage label Jan 31, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Jan 31, 2019
@ericsnowcurrently ericsnowcurrently added info-needed Issue requires more information from poster and removed triage labels Jan 31, 2019
@ericsnowcurrently
Copy link
Member

Considering that this is an app-specific .env file, we can dictate the format for substitution and stick with what is the defacto standard (regardless of platform or shell). The substitution will happen in IEnvironmentVariablesService.parseFile(), so the terminal case is not impacted.

@ericsnowcurrently ericsnowcurrently removed the info-needed Issue requires more information from poster label Jan 31, 2019
@ericsnowcurrently
Copy link
Member

FTR...

There are three sorts of `env' files out there:

In the extension:

Highlighting in VSCode:

Node:

@ericsnowcurrently
Copy link
Member

There should be a docs update to go along with this. @DonJayamanne, how do I get that rolling?

@DonJayamanne
Copy link

how do I get that rolling?

File an issue on https://github.com/Microsoft/vscode-docs

@ericsnowcurrently
Copy link
Member

FWIW, the philosophy on .env files from the dotenv module isn't compatible with our needs. This became clear in conversations on upstream PRs:

ericsnowcurrently added a commit that referenced this issue Feb 8, 2019
(for #3275)

Notable:

* only simple substitution is supported (via `${NAME}`; no nesting)
* substitution can be made relative to the current env vars
* recursion (setting var relative to itself) is supported
* stopped using `dotenv` module (doesn't preserve order)
* any invalid substitution causes value to be left as-is
* adds the `ENVFILE_VARIABLE_SUBSTITUTION` telemetry event
@ghost ghost removed the needs PR label Feb 12, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 12, 2019
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

5 participants