-
-
Notifications
You must be signed in to change notification settings - Fork 513
allow warning when a env var was not overwritten #531
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
Conversation
bkeepers
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pull request! I get the frustration when you realize that a local variable was set and couldn't figure out why something was not working.
Would it make sense to warn by default? I wonder if there's a clean way to say which variables were set from .env and which were already set.
lib/dotenv.rb
Outdated
| overwrite ? new_value : old_value | ||
| case overwrite | ||
| when :warn | ||
| warn "Warning: Not overwriting ENV['#{key}'] with '#{new_value}' (is '#{old_value}')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this use the logger instead of warn? I am also hesitant about printing the values because they could contain secrets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah good point, keys should be enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... how do you suggest using the logger, in non-rails there is no logger right ?
removed the values and changed to .inspect just in case there is some escaping to be worried about
|
re "warn by default" afaik no other dotenv library does that, so I'd rather not make that the default |
|
also added gem name to warning so people have a chance of knowing what is going on |
* main: Fix lint error Remove sponsor feat: remove to_sentence usage Add test for command to variable to command Handle parentheses in variables in commands
* main: Bump actions/checkout from 4 to 6 fix a few small issues
too many times I'm trying to debug someones issues and it's "oh you already set xyz api key in your env" 🤦
so
Dotenv.load files, overwrite: :warnwould tell them that it's already set.... might also get annoying after a while 🤷 but wanted to raise an issue since this seems be a common gotcha
might want to make it set+warn instead, to keep the
override is truthybehavior, lmkFYI similar but hacky way of doing it: