logoalt Hacker News

threecheesetoday at 7:59 PM8 repliesview on HN

Am I weird or old-fashioned for relying on direnv over .env? These days my projects use a lot of different tech, and it just feels weird to me to have them all parsing .env files and hoping everything works. Especially with inference provider tokens basically connecting my checking account to the internet.


Replies

curun1rtoday at 9:20 PM

The concept is fine, but I'm a big fan of doing it with mise instead. It does the exact same thing plus a lot of other things really well. The environment for a project is not just things that get stored in environment variables, it also includes specific versions of tools, common project tasks, git hooks and such. Being able to manage all of that in one place ends up being really useful.

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).

show 1 reply
dolnitoday at 9:09 PM

Dotenv is definitely something that should not exist.

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.

LawnGnometoday at 8:51 PM

No, I also use direnv. It does everything I want, nothing I don't, and has been stable for me for years.

wrenkytoday at 8:25 PM

direnv + nix flakes solved so many problems for me, I have no idea how other people work on multiple projects at the same time without getting mixed up.

drdexebtjltoday at 9:28 PM

A bonus is that with that approach, you actually have real environment variables.

stock_toastertoday at 8:27 PM

I also used to use direnv (and likewise eschewed .env), but more recently I moved env definitions to mise. Been working out nicely.

PufPufPuftoday at 9:04 PM

I use Mise for env. I primarily use it for installing tools and running tasks, having env support is just a cherry on top.

paulddrapertoday at 8:29 PM

Direnv's first stable release was in 2013, .env was 2012 (adopted by Heroku).

So no, if anything direnv makes you hip and edgy.