-
Notifications
You must be signed in to change notification settings - Fork 275
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
dotenv integration captures quotes in value/improperly stores json #772
Comments
Seems like we'll want to cover these tests https://github.com/theskumar/python-dotenv/blob/main/tests/test_parser.py We'd want to use https://github.com/tweag/nix-unit-testing/tree/main/flake to write the tests. |
#718 can also fix this issue by offloading the whole parsing logic to the shell. It also means that I was looking into tweaking the regex used in @domenkozar What do you think? |
My worry is that if someone relies on those variables to be used in Nix, this will stop working. |
I don't know if this needs a new issue or not, but the regex in question also seems to cause problems with values that have I will second the ability to have the .env variables accessed in Nix is pretty useful. It lets me easily parameterize parts of an environment variable across environments, such as the port of the database url in the example above. |
Yeah, on second thoughts, I can use direnv to source I have a regex that can handle comments and values with |
I am not sure if it is a good idea to access .env variables in nix expressions. For example, if you create a script via |
Describe the bug
When using quoted json in
.env
the resulting environmental variable includes both the quotes and json. If something like "read" in Haskell is called on that environmental variable it will predictably fail.The reason is because of this regex in the dotenv integration:
Which results in the single quotes being in the resulting value:
I can get the expected behavior by optionally matching
'
, but this might not be how you want to write it:Some related issues:
theskumar/python-dotenv#35
theskumar/python-dotenv#285
theskumar/python-dotenv#381
To reproduce
Please provide an Short, Self Contained, Correct (Compilable), Example by creating a gist using
devenv.nix
,devenv.yaml
, and optionallydevenv.lock
.Given
.env
:Running
echo $data
with dotenv integration enabled results in:I would expect only the json value and not the surrounding single quotes to be captured.
Version
Paste the output of
$ devenv version
here.The text was updated successfully, but these errors were encountered: