0

I am using a Mac. When I tmux new-session -s will new a session with a window with duplicate $PATH entries in random order, which is different from these outside Tmux.

However if I C-b c to create a new window inside the same Tmux session, $PATH entries will be normal and correct again. I totally get lost and want to know how to debug this.

This will cause some of my script that I wrote for Tmux fail to execute. The script worked very well before but are not working now.

0

Duplicate env var keys, if their corresponding values are the same, are no reason for a script to fail.

Make your script deal with redundant information gracefully and to only abort if different values are coming for one same single key.

  • Thanks. You are right for most cases. But what my script do is actually to new a tmux session and activate a conda env automatically. With the duplicate and wrong order PATH, the conda activate myenv will fail to work. However if I C-b c to create a new window inside the same tmux session and conda activate myenv, then everything is fine. – H.Li Sep 10 '19 at 8:29
  • I don't troubleshoot Anaconda. Once you got some other better answer, I'll remove this. – 174140 Sep 10 '19 at 8:37
  • Maybe it's related to shell interactivity, the bashrc and the Bash user profile. – 174140 Sep 10 '19 at 11:29
0

Finally I find that tmux will always call the profile for your shell, not just the rc. So if you are using bash like I do, it will call /etc/profile, which will have a call to path_helper.

In order to fix this, change /etc/profile to:

if [[ -z $TMUX ]] && [ -x /usr/libexec/path_helper ]; then
        eval `/usr/libexec/path_helper -s`
fi

If you are using bash, also change any export PATH=$PATH:/foo in .bashrc to

if [[ -z $TMUX ]]; then
  export PATH=$PATH:/foo
fi

then you restart the terminal(for example Iterm). Everything should be good!

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.