News for hackers. Stuff that matters.
Re:Be Careful Using Tmux and Environment Variables by ajorgensen on Saturday March 04, 2023 @11:52AM (#35022260)
OP here. Apologies for not providing the real world example that triggered the behavior but here's some more background: We have some make tasks that set up a local dev environment and rely on environment variables to control a few things. We ran into an issue where if someone started another tmux session and then ran the make task to start the dev environment the env vars wouldn't be set correctly causing some confusing behavior.

Ultimately we decided to use a named tmux socket to ensure the environment variables were picked up correctly when set via the make task but you can also use `set-environment` as well if the ergonomics hit of having to use the named socket each time is too much. It's nice that tmux provides a few work arounds but I thought the original behavior was not intuitive.

Re:Be Careful Using Tmux and Environment Variables by trollied on Saturday March 04, 2023 @03:11PM (#35024046)
Surely you'd run a script as part of your task to make sure it was all set correctly? This just seems like a bad setup.
Re:Be Careful Using Tmux and Environment Variables by bb88 on Saturday March 04, 2023 @05:14PM (#35025004)
If you thought you were reloading the dev environment database, and found out you just reloaded your production database, you would be surprised too. And you would probably wonder why after setting the dev variables, the tmux shell didn't have them.

It's one of those rare gotchas that will bite someone in the ass. And it will hurt. And when it does, you'll swear like a mother f'er.