3 ms·
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 d
by kelnos 3y ago
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 "hidden behavior" for me to forget about and then get surprised by.
- TheRoque 3y agoAs far as I'm aware of, Direnv's behavior is not hidden at all. Whenever you cd into the directory, you get a message listing all the new en var activated. And when you change the .envrc, you get another message saying that direnv has been deactivated. I never had happen to me "oh shoot !! I forgot this env var was activated because I'm in this dir".
- 3836293648 3y agoOh yeah, that's the default. Everyone I know im ediately disabled that and I even forgot about it till now
- macintux 3y agoI don't think "hidden" and "explicit" are true antonyms. From your description, direnv is implicit and noisy, whereas dotenv seems to be (unless you embed it in a script) explicit and quiet.
- TheRoque 3y agoWell basically, you cd in the shell, and then it shows: "direnv: loading ~/dev/foo/.envrc direnv: export +DATABASE_URL" Is this "implicit" to you ? Because to me it's pretty explicit. But yeah it's automatic, if you don't want this behavior, you don't install direnv. Just to be clear, implicit is "suggested but not communicated directly", and to me, this is communicated directly, so I don't see why it would be implicit...
- cortesoft 3y agoWhat happens when, 30 commands later, you execute a command in your shell and didn't remember that message from a day or so ago?
- malicka 3y agoIt’s the same as forgetting you put something in your .profile or .bashrc, no? In any case, both forgetting the env config and using the same shell for days in a row seem like two things that probably don’t coincide too often.
- jeffhuys 3y agoI never close my shell, I never reboot my laptop unless necessary - an uptime of 6+ months is normal. So my experience may be different.
- withinboredom 3y agoHow do you deal with kernel security patches?
- kreetx 3y agoOf you're in the directory, don't you want the env to be loaded? For me, being able to forget it is one of the features.
- steezeburger 3y agoNot always. I can think of a scenario where I have an env I need to load for some infrastructure stuff, and I may call some commands in a directory that has another .env that's part of what I'm trying to deploy. Generally this scenario is short lived as I'm quickly moving infra commands to automated ci/cd, but I've definitely been in this scenario more than once.
- kreetx 3y agoGot it! I think nested envs become confusing really quickly, so there it is indeed better to do it explicitly. My assumption overall in this is that most people have just one .env per project (or perhaps in sub-folders per environment, e.g prod, staging, local), but these don't nest. With nested .env files, the mental overhead they bring remove (IMO) most of the benefits, if not more.