allan2 / dotenvy

A well-maintained fork of the dotenv crate
MIT License
664 stars 40 forks source link

Questionable behavior on empty predefined env #9

Closed sakulstra closed 2 years ago

sakulstra commented 2 years ago

Hey reporting this here as it seems to be the successor of dotenv crate that's currently used in https://github.com/foundry-rs/foundry

I noticed some weird behavior of dotenv which i think is still present in dotenvy :sweat_smile:

# .env file contents
TEST=test

Will correctly load TEST, but when i use export TEST= (to pollute the env) it will no longer work which is somewhat unexpected.

I understand that machine env > .env by design, but having an empty env defined is imo very close to not having an env defined so .env should take precedence. All other dotenv libraries i ever faced behaved differently.

tl;dr; I think it make sense to enhance this check https://github.com/allan2/dotenvy/blob/master/dotenv/src/iter.rs#L28 to be either error or empty string, so that .env takes precedence over predefined empty strings.

allan2 commented 2 years ago

Hi @sakulstra, could you provide a minimal working example so I can understand your issue better?

sakulstra commented 2 years ago

@allan2 sorry when trying to create a reproduction noticed an issue in my implementation which lead to the issue mentioned above :sweat_smile: