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

Option for whether or not System ENV values are overwritten or preserved #42

Open
fireproofsocks opened this issue Apr 1, 2021 · 1 comment

Comments

@fireproofsocks
Copy link

The System.put_env/1 call is pretty heavy-handed. It would be nice to allow an option to control whether values in an .env would overwrite existing ENV values or not. I'm thinking of use cases as straight-forward as this:

An .env has some values like:

LOG_LEVEL=warn
# other values...

and then you want to override a value, so you supply the value in the command, e.g.

LOG_LEVEL=debug iex -S mix
# or
LOG_LEVEL=debug _build/myapp

In both cases, the expectation is that the supplied ENV value would override anything already exported to the system.

Perhaps this option could be made available to the Dotenv.load functions, e.g.

Dotenv.load(".env", overwrite: true)

I think the default behavior would be to not overwrite existing values.

@iloveitaly
Copy link
Collaborator

Could you explain the use case behind this? In what scenario would this be helpful to you?

I'm a fan of following the ruby dotenv implementation which assumes that the vars in .env should overwrite any previous values based on the load order of dotenv. This makes intuitive sense to me, but I'm curious to learn more about an alternative take.

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