-
-
Notifications
You must be signed in to change notification settings - Fork 317
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
Clearly specify .env
file syntax (not like Docker, not like Bash; it's something else)
#278
Comments
In particular, the output of |
I am not an expert but sincerely understanding the syntax of dict form the 2 lines of the project description is difficult :
|
As I'm now reviewing issues, I've stumbled up (again) with this one, and I'd like to share something. @joke2k I think stating clearly which features and expectations on the "standard" will Hey, maybe even in a distant future, if the lib is made extensible, people can build their own "specific parsings" on top as some sort of add-on. |
The supported syntax of the
.env
file needs to be better specified (possibly as part of #88, but this may be a bigger issue than just that ticket).Reading the regex-based parsing, it's clear that
django-environ
tries to support something bash-ish - it strips leadingexport
declarations at the beginning of the line, and does some rudimentary quote processing (just stripping matching'
or"
at the beginning and end).However:
.env
files. Docker does no quote parsing, so beginning/trailing quotes are considered as part of the value. An.env
file that works indjango-environ
may not work in Docker. An example failure: a quoted JSON string likeVAR='{"key": "value"}'
will work indjango-environ
, but fail if Docker has parsed.env
and populated the environment with it; the wrapping'
will be retained and not be valid json.django-environ
.In sum, the current behavior is:
VAR=VAL
in single lines.export
keywords are stripped.VAL
is wrapped in single or double quotes, those are stripped; but no further resolution of internal quoting structure is done.Expecting a single
.env
file to successfully target more than one of Docker, django-environ, or bash is looking for trouble; care must be taken for what other contexts populate the environment from.env
beforedjango-environ
runs. Docker-parity can be achieved by avoiding all wrapping quotes in the.env
values, so long as no value requires wrapping quotes as part of its content. Bash parity is probably not possible without using a bash interpreter to parse the file.The text was updated successfully, but these errors were encountered: