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

Listing multiple .env files should source them sequentially even when env_override_existing_values is not set #22

Open
maxmelamed opened this issue Feb 16, 2022 · 1 comment

Comments

@maxmelamed
Copy link

Hey there! I'm using this plugin and I've noticed the following behavior, which is somewhat confusing. If I have my pytest-dotenv config as follows:

env_files =
    .env  <-- defines FOOBAR=5
    .env.test  <-- defines FOOBAR=7

then I end up with FOOBAR=5.
I understand this can be fixed with env_override_existing_values=1, but the docs seem to suggest that this is intended for overriding existing env vars in the current process, rather than env vars in a previously listed file. In my opinion, it would make sense to overwrite values from previously specified env files by default, while leaving env_override_existing_values=1 for deciding whether or not existing env vars in the process should be overwritten.

I'd be happy to open a PR if the proposed behavior makes sense.

@ikonst
Copy link

ikonst commented Feb 17, 2022

One thing to note is that'd be a breaking change, since currently the inverse would work (putting .env.test first) and if you make that change, this will no longer be true. A possible solution is to make this a documented behavior (to list env files in reverse).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants