4

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!

7
  • 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, 2017 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. Jun 6, 2017 at 18:41
  • Maybe it's coming from .tmux.conf?
    – Barmar
    Jun 6, 2017 at 19:02
  • I checked that as well. Also no :( Jun 6, 2017 at 20:29
  • I'll edit my question to include a list of files I've checked, that might be helpful. Jun 6, 2017 at 20:30

2 Answers 2

4

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
2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .