I also really like that for sensitive variables (AWS tokens, prod DB passwords, etc), I can keep those in a dedicated secret store (I use 1Password for personal projects and there are more enterprise focused alternatives for work).
direnv does one thing really well, and it enables a large ecosystem of other components that you can pick and choose to build developer environments. SecretSpec, from the featured article, is one such component which pairs really well with direnv, and has the features you’re describing for secrets.
I think direnv’s approach is the one with more staying power.
It also doesn't work well. And they have no support outside of Discord chat.
Direnv is the right way to go if you want a tool for this. Otherwise dotenv's implementation in bash is essentially `set -a; source .env`. Look ma, no custom parser!
Seems really silly to have a library do what two lines of shell can reasonably accomplish.
Which is dumb. The canonical spec for .env should just be "whatever POSIX sh does."
One of the major benefits of a shell-based approach is your env vars could be generated from the output of a command.
Which can be trivially used to populate secrets from whatever your secret store of choice is.
Now we've also cleanly solved secret distribution for developers with one less dependency!
Though the obvious fix is to use single quotes in the .env file.
So no, if anything direnv makes you hip and edgy.