7

inside shell when

which conda

I get

/anaconda3/bin/conda

while inside tmux I get

/anaconda3/condabin/conda

Anyone knows the difference or something wrong with my config?

Ken Williams
  • 22,756
  • 10
  • 85
  • 147
H.Li
  • 171
  • 2
  • 12
  • I'd guess it probably has to do with tmux sessions not sourcing `.bashrc` (or whatever shell you have). E.g., see [this question](https://stackoverflow.com/questions/9652126/bashrc-profile-is-not-loaded-on-new-tmux-session-or-window-why). – merv Jun 03 '19 at 04:39
  • @merv Now, I reinstalled anaconda3. Both shell(I use iTerm) and tmux will give me /anaconda3/condabin/conda. I am sure I source .bashrc and .bash_profile manually. I found a similar case [here](https://github.com/Microsoft/vscode/issues/69954). But still no idea how to fix it. Any suggestion? thanks – H.Li Jun 03 '19 at 09:46

2 Answers2

3

Finally I found an answer here that worked for me. Basically as @shouya said there, this problem is because tmux's run-shell command runs a shell which doesn't read from user configs, thus tmux installed in /usr/local/bin will not be found. And best solution is to insert the following line:

set-environment -g PATH "/usr/local/bin:/bin:/usr/bin"

before the first run-shell/run command in your ~/.tmux.conf file, and leave everything else untouched. Then reload ~/.tmux.conf file by

tmux source-file ~/.tmux.conf
H.Li
  • 171
  • 2
  • 12
2

Just to address what the primary question: Conda sets up condabin as a directory to always keep on PATH primarily so that the conda command can be available when base is not activated.

When you have base activated, running which conda will find bin/conda first on PATH; any other time condabin/conda will be found.

The issue in OP indicates the tmux session is not activating the base environment.

merv
  • 67,214
  • 13
  • 180
  • 245