dotenv-rs / dotenv

Library to help supply environment variables in testing and development
MIT License
557 stars 85 forks source link

Override existing ENV variables #44

Open askoretskiy opened 4 years ago

askoretskiy commented 4 years ago

I miss one thing that could be helpful for others -- there is no way the library would override existing env variable via .env file. Sometimes it is needed though.

For example, I'd like to override PATH. If I create a file .env with PATH=/opt/bin:${PATH} that would have no effect.

Did you consider any modificator for KEY? Maybe, !? That could mean to override existing env variable.

In my case that would be !PATH=/opt/bin:${PATH}.

What do you think?

Plecra commented 4 years ago

https://github.com/bkeepers/dotenv implements this as an alternative entrypoint. Would something like that be suitable for your use case?

msrd0 commented 2 years ago

I think a separate entrypoint would be helpful

MaxFangX commented 2 years ago

I agree that (if implemented) this should be done as a separate entrypoint. The current behavior is ideal for me, because I can override the variables in .env in one off commands like FOO=1 cargo build