This article reads like more of an ad than anything else. > Environment variables only deliver values Yes, the problem .env files try to solve is having "environment variables" be injectable from a file so that different applications can have different environment variables by default. > A string is not a schema Yes, input validation is an application concern. The application should know what these values represent /…
> Yes, the problem .env files try to solve is having "environment variables" be injectable from a file so that different applications can have different environment variables by default. This seems like a misunderstanding: The `.env` file should be `source`d into the current shell (environment). The application reads values using whatever mechanism it uses to read these values from the environment. Nothing should be…
Where .env Went Wrong
51–60 of 77 posts
Re: Where .env Went Wrong
#52Earlier quoted context omitted.
> Yes, the problem .env files try to solve is having "environment variables" be injectable from a file so that different applications can have different environment variables by default. This seems like a misunderstanding: The `.env` file should be `source`d into the current shell (environment). The application reads values using whatever mechanism it uses to read these values from the environment. Nothing should be…
Does it matter whether the app reads `.env` directly though?
Re: Where .env Went Wrong
#53I can't understand for the love of me why our industry settled on env as The Way to store configuration. It's poorly discoverable, it's a shared namespace polluted by everyone and their `libdog`, it's stringly typed, etc. All of that just flies in the face of otherwise accepted dev wisdom. I love Django's approach to configs: your config is just a plain old Python file with some constants. As simple as possible, and…
Re: Where .env Went Wrong
#54Are these valid observations so far?
- .env is the simplest and oldest / most boring solution. Secrets are passed to teammates by DM?
- .env.example seems like a nice home for documentation about secrets
- but I'd rather avoid writing sensitive credentials at all -- instead, teams can use a cloud-based secrets manager and the project fetches secrets at runtime. Is this ever a hassle / any downsides? How standard is this practice these days? I hear this also helps updating secrets so you don't have to e.g. tell every teammate when you rotate a secret. Generally not a fan of introducing a network call and a saas dependency, tho
- non-sensitive environment variables also need a home. I don't like the idea of cluttering the project with a .env.local or worse like .env.development.local
- I hear lots of secrets and config management happens in container orchestration, but what if I barely have a container in the first place? I guess docker compose is one of the simplest tools at this layer?
I guess I'm just looking for a safe, simple solution for a small team, and maybe the problem is that every team does things differently, and that many tools are marketed towards huge enterprise teams.
Re: Where .env Went Wrong
#55This was really popular, and lots of people bought the factor III of only configuring via environment variables.
The whole point of it was: keep config simple. Env vars are austere and will keep you from complexity.
But people found a way to complicate them, so they could have both the 12 factor literal pass and the complexity they wanted.
That resulted in the mess we are today.
Re: Where .env Went Wrong
#56Hey cool, a relevant place to mention my project: https://dotprot.dev/ Type "dotprot" to copy your .env file into 1Password using the 1P CLI, it verifies it's there, then deletes the local copy of .env. When you're ready to work again, type "dotprot" again to restore the .env file from 1P. There is a .prot file in the directory that you can declare other files to store in 1P as well. Varlock ( https://varlock.dev ) i…
Re: Where .env Went Wrong
#5792% of this text is detected as AI. It may be time for Hackernews to integrate a Pangram detector into the UI, similar to what substack is doing :)
Re: Where .env Went Wrong
#58Personally, I tend to have a `source ./source-me-auth` which does stuff like `DB_PASSWORD="$( pass show blah.com | head -1 )"`, but that still means I end up with secrets dangling around in my environment. The "source-me" file is safe to share, but my runtime environment is tainted (for good and bad...).
I saw something w.r.t. the way open-claw handles things where you basically say `export DB_PASSWORD="REDACTED@SECRET_001"` and then it basically outbound filters network requests to hydrate that with `s/REDACTED@SECRET_001/$REAL_SECRET/g`, and I _really_ like that mechanism b/c it defers secret usage to runtime and keeps it physically "out" of the application itself.
Basically, having `with $SECRETS -- some_app.sh --some params ...` wouldn't be terrible (conceptually).
Re: Where .env Went Wrong
#59Hey cool, a relevant place to mention my project: https://dotprot.dev/ Type "dotprot" to copy your .env file into 1Password using the 1P CLI, it verifies it's there, then deletes the local copy of .env. When you're ready to work again, type "dotprot" again to restore the .env file from 1P. There is a .prot file in the directory that you can declare other files to store in 1P as well. Varlock ( https://varlock.dev ) i…
Re: Where .env Went Wrong
#60Earlier quoted context omitted.
The fact that it's hidden means it doesn't get commited by accident in most git repos unless explicitly added or configured that way.
there shouldn't be any secrets in it so committing it shouldn't be a huge problem.
Granted, but on the other hand: the entire history of this profession.