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

Add option not to override existing env variables #16

Merged
merged 1 commit into from Jul 15, 2023

Conversation

mpeteuil
Copy link
Owner

@mpeteuil mpeteuil commented Jul 15, 2023

The reason the default behavior of this plugin is to override existing environment variables 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.

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. Here we add a system environment variable—POETRY_DOTENV_DONT_OVERRIDE. I think it should solve most cases. This is because 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.

This resolves #14

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](https://github.com/pypa/pipenv), many switching to
Poetry. [Pipenv had built-in `.env`
loading](https://pipenv.pypa.io/en/latest/shell/#automatic-loading-of-env)
which [did override by default (and still
does)](https://github.com/pypa/pipenv/blob/98bdb5f8b2f08a435a825915d7d7d215a7aaec19/pipenv/utils/environment.py#L37).
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](https://github.com/mpeteuil/poetry-dotenv-plugin#coming-from-pipenv).

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`. Here we add a system environment
variable—`POETRY_DOTENV_DONT_OVERRIDE`. I think it should solve most
cases. This is because most users who want it to [behave like
`python-dotenv`'s
defaults](https://github.com/theskumar/python-dotenv#getting-started)
probably want that everywhere and the same for anyone who wants it to
behave like `pipenv`.
@mpeteuil mpeteuil force-pushed the dont-override-env-vars-option branch from a111e50 to b3b09a1 Compare July 15, 2023 23:03
@mpeteuil mpeteuil merged commit 22eaf2d into main Jul 15, 2023
12 checks passed
@mpeteuil mpeteuil deleted the dont-override-env-vars-option branch July 16, 2023 12:15
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

Successfully merging this pull request may close these issues.

Default override behavior is reverse of python-dotenv
1 participant