2

I'm having a really strange problem. Tmux is exporting an environment variable that I used to have exported in my ~/.bashrc, but which I have since removed (let's just call this $MYSTERIOUS_ENV_VAR. When I'm in a tmux session and I run echo $MYSTERIOUS_ENV_VAR, it continues to output the path that I used to have exported in ~/.bashrc. However, when I run this same echo command in a normal shell (not in tmux), it gives me back nothing, which is what I'd expect.

I've checked my tmux configuration and my shell startup files and I'm not exporting this anywhere, so I'm really confused about where it's coming from - to be thorough, these are the files I have checked:

  • ~/.bashrc
  • ~/.tmux.conf
  • ~/.bash_profile

If it helps, the environment variable that I'm exporting is $PASSWORD_STORE_DIR, which is used for the open source password management program, pass. I used to have it point to a custom location, but I removed the export so that my passwords would save to the default location, $HOME/.password-store.

I feel like I've done something silly and that it's a simple problem, but cannot seem to figure out what it is. Any help would be very much appreciated!

  • Are you in a tmux session that you started before you changed .bashrc? It still has all the environment variables that it had when you started. – Barmar Jun 6 '17 at 15:24
  • I thought this might be the case, but I've tried exiting the tmux session and restarting the terminal app (I'm on OSX) altogether. But the issue persists even in new tmux sessions. – 3cheesewheel Jun 6 '17 at 18:41
  • Maybe it's coming from .tmux.conf? – Barmar Jun 6 '17 at 19:02
  • I checked that as well. Also no :( – 3cheesewheel Jun 6 '17 at 20:29
  • I'll edit my question to include a list of files I've checked, that might be helpful. – 3cheesewheel Jun 6 '17 at 20:30
2

tmux can unset environment with

tmux set-environment -r MY_ENV_VARIABLE

So in your case it should be

tmux set-environment -r PASSWORD_STORE_DIR
| improve this answer | |
1

You have to kill all of your existing tmux sessions to resolve this.

I don't know why you have to do this, and it seems really silly, but I run into this issue constantly with ZSH + tmux whenever I update my proxy environment variables and killing all of my tmux sessions is the only way to get new panes even in new sessions to stop re-exporting old environment variables.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.