Skip to content
New issue

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

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

Already on GitHub? # to your account

Default override behavior is reverse of python-dotenv #14

Closed
mahiki opened this issue May 26, 2023 · 1 comment · Fixed by #16
Closed

Default override behavior is reverse of python-dotenv #14

mahiki opened this issue May 26, 2023 · 1 comment · Fixed by #16
Labels
enhancement New feature or request

Comments

@mahiki
Copy link

mahiki commented May 26, 2023

The default behavior of this plugin is to override the existing env variables, unlike the default in python-dotenv.

As shown in the python-dotenv docs, default is to not override env variables, in other words in python-dotenv the .env variables can be overridden by exporting a variable into the current environment.

With python-dotenv you can do load_dotenv(override=True) when you want .env file to override. Unfortunately, the poetry-dotenv doesn't allow the user to manage this aspect, its always going to override.

I think this is unexpected behavior for people who use python-dotenv.

Is there a way to set the poetry dotenv plugin to stop overriding existing environment variables?

@mpeteuil
Copy link
Owner

👋 Hello! The reason the default behavior of this plugin is what it is, is because it has origins during the time when there were a lot of users migrating away from Pipenv, many switching to Poetry. Pipenv had built-in .env loading which did override by default (and still does). In order to support the many people coming from pipenv the goal was to make the fewest changes from that toolset possible in regards to .env loading. That is also why there are other some analogous environment variables between this project and pipenv with a section about them in the README.

I agree that if you're coming from vanilla python-dotenv then this is unexpected. That needs to be reconciled with the expectations of anyone coming from pipenv. My proposal to resolve this is a system environment variable—POETRY_DOTENV_DONT_OVERRIDE—which is being added with #16. I think it should solve most cases. Most users who want it to behave like python-dotenv's defaults probably want that everywhere and the same for anyone who wants it to behave like pipenv.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants