tmux, zsh, and rbenv: part ii

This is a follow-up to a previous post.

I thought I had things figured out, but things were only working for me because my environment was setup the way I wanted prior to starting tmux. It seemed that when the parent shell loads rbenv, then tmux starts up and runs subsequent shells inside that environment, rbenv no longer functions properly. That is, it acts like it’s functioning, but you can’t actually change Ruby versions.

The Solution

Instead of having in my ~/.zshenv:

eval "$(rbenv init -)"

I’ve changed it to:

if [ -n "$TMUX" ]; then
  eval "$(rbenv init -)"
fi

This means that outside of my tmux environment, rbenv will not be loaded. This should not be an issue [for me] because I am always in a tmux environment of some kind. If not, I could manually init rbenv or just use system Ruby, which is 2.0 under Mavericks.