9

tmux is auto setting RBENV_VERSION when I start tmux...

Anyone know how to stop it?

Because it auto sets it, I need to do

$ export RBENV_VERSION

to unset it and make .ruby-version work. Thx.

Takehiro Adachi
  • 954
  • 1
  • 9
  • 22

2 Answers2

15

tmux itself will never set (or unset) RBENV_VERSION of its own accord. You have some bit of configuration that is causing this.

My guess is that RBENV_VERSION was set when you started your tmux server and that is is now part of the tmux “global environment” (the base environment inherited by all the processes started by tmux). You can check this

tmux show-environment -g | grep RBENV

If it is present there, you can delete it with this command:

tmux set-environment -gu RBENV_VERSION

If you often find yourself starting tmux when RBENV_VERSION is already set (and you do not want it sent “inside” tmux), then you can add the above command to your ~/.tmux.conf file to make sure that it is cleared every time you start a server.

Another possibility is that it is part of your tmux “session environment”; this environment is “layered” atop the global environment to form the environment that is inherited by the processes started for new windows and panes in a session. You can check it with this command (run it inside the session, or add -t sessname to specify a session):

tmux show-environment | grep RBENV

If this is present, you can unset it in a similar way:

tmux set-environment -u RBENV_VERSION

Finally, if the variable is not present in either the global or session environments, then it is probably coming from something in your shell initialization files. By default, tmux starts login shells, so be sure to check the corresponding bits of shell configuration (e.g. .bash_profile, .bash_login, .profile, etc.) as well as any other bits of initialization.

Chris Johnsen
  • 214,407
  • 26
  • 209
  • 186
0

To check if an environment variable is part of tmux's session environment, look at the output of

tmux show-environment

and then do the same for the global environment:

tmux show-environment -g

tmux starts login shells by default, so you could clear the global environment and let the login shells build it from scratch (from ~/.profile and so on). Here is a way to do that:

(tmux show-environment -g |less |sed 's/=.*//' |while read e; do tmux set-environment -gu -- "$e"; done)
Tobu
  • 24,771
  • 4
  • 91
  • 98