Dotenv
Dev tools
environment variable loader
SHOW HN2024
How HN took it
2 positive, 6 neutral or asking, 0 mixed, 12 critical, out of 20 comments about the project. Thread score -0.44.
Idea: 2 for, 11 againstDocs: 0 for, 1 against
The thread, comment by comment
Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.
positive neutral or mixed critical about another commenter or something else the maker
What HN said
What people liked
Explicit invocation avoids hidden environment behavior
From 1 comment
I've used direnv, but I think a nice property of OP's dotenv is that it's explicit: if I want to pass env vars, I run my program under it. If I don't, then I don't. There's no…
kelnos on HN
Objections
Sourcing .env in shell is simpler and already works
From 3 comments
Would not sh -c '. .env; echo $MY_VAR' do the same thing? (I am not in front of a shell at the moment.)
mongol on HNPlease just see this `env -S "$(cat .env)" <cmd>` Believe it or not that’s all you need. > S, --split-string=S process and split S into separate arguments; used to pass multiple…
tuyiown on HNI don't understand what more it does than sourcing a file on your shell would? Anyone can explain?
prmoustache on HN
Existing tools like direnv and dotenvx already cover this
From 2 comments
I think direnv already does a good job in this space, and it's already available in your package manager. https://direnv.net/
petepete on HNCompare with dotenvx - https://github.com/dotenvx/dotenvx This is my current tool of choice.
grounder on HN
Whitespace and comment handling breaks naive env $(cat .env) approaches
From 3 comments
This will fail with comments. Of course you can script around that as well (I have done so), but it's not bulletproof. It makes sense to have a dedicated tool for the job.
ibotty on HNHas whitespace handling issues... but valiant effort!
arjvik on HNWhen your environment variable values have spaces (e.g. some connection strings) this doesn’t work iirc
fire_lake on HN
Requests
Compatibility with Docker env file format
From 1 comment
Does this accept the exact same format (including quotes and whitespace) as a Docker env file? That’s a key feature for me
fire_lake on HN
Questions
What does it do beyond sourcing a file in the shell
From 1 comment
I don't understand what more it does than sourcing a file on your shell would? Anyone can explain?
prmoustache on HN
Alternatives named
direnv
From 1 comment
I think direnv already does a good job in this space, and it's already available in your package manager. https://direnv.net/
petepete on HN
dotenvx
From 1 comment
Compare with dotenvx - https://github.com/dotenvx/dotenvx This is my current tool of choice.
grounder on HN
shdotenv
From 1 comment
There is also shdotenv that allows you to load different .env file formats and convert between them, e.g. for UNIX shell. https://github.com/ko1nksm/shdotenv
miohtama on HN
dotenv-cli npm package
From 1 comment
Doesn’t this already exist as https://www.npmjs.com/package/dotenv-cli ?
vishvananda on HN