Repository: conda/conda

Issue:
Base environment PATH is not set when transitioning to tmux
<!--
Hi!

This is an issue tracker for conda -- the package manager.  File feature requests
for conda here, as well as bug reports about something conda has messed up.

If your issue is a bug report or feature request for:
  * a specific conda package from Anaconda ('defaults' channel):
      ==> file at https://github.com/ContinuumIO/anaconda-issues
  * a specific conda package from conda-forge:
      ==> file at the corresponding feedstock under https://github.com/conda-forge
  * repo.continuum.io access and service:
      ==> file at https://github.com/ContinuumIO/anaconda-issues
  * anaconda.org access and service:
      ==> file at https://anaconda.org/contact/report
  * commands under 'conda build':
      ==> file at https://github.com/conda/conda-build
  * commands under 'conda env':
      ==> please file it here!
  * all other conda commands that start with 'conda':
      ==> please file it here!

-->

**I'm submitting a...**
  - [x] bug report
  - [ ] feature request


## Current Behavior
<!-- What actually happens?
     If you want to include console output, please use "Steps to Reproduce" below. -->
After a clean installation of anaconda and an update to conda 4.4.7 everything seemed to be working nicely. On restarting, I have found that the base environment is not activated correctly. The PATH is not being set, so only the system python installation is on the path. Activating any other environment sets the PATH correctly, but the base environment does not.

I'm running Ubuntu 16.04.

### Steps to Reproduce
<!-- If the current behavior is a bug, please provide specific, minimal steps to independently reproduce.
     Include the exact conda commands that reproduce the issue and their output between the ticks below. -->
```
conda activate base
which python
> /usr/bin/python
conda activate other-environment
which python
> /home/me/anaconda3/envs/other-environment/bin/python
```


## Expected Behavior
<!-- What do you think should happen? -->


## Environment Information
<details open><summary><code>`conda info`</code></summary><p>
<!-- between the ticks below, paste the output of 'conda info' -->
'conda info':

```
     active environment : service.thickener.pde
    active env location : /home/me/anaconda3/envs/service.thickener.pde
            shell level : 2
       user config file : /home/me/.condarc
 populated config files : 
          conda version : 4.4.7
    conda-build version : 3.0.27
         python version : 3.6.2.final.0
       base environment : /home/me/anaconda3  (writable)
           channel URLs : https://repo.continuum.io/pkgs/main/linux-64
                          https://repo.continuum.io/pkgs/main/noarch
                          https://repo.continuum.io/pkgs/free/linux-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/r/linux-64
                          https://repo.continuum.io/pkgs/r/noarch
                          https://repo.continuum.io/pkgs/pro/linux-64
                          https://repo.continuum.io/pkgs/pro/noarch
          package cache : /home/me/anaconda3/pkgs
                          /home/me/.conda/pkgs
       envs directories : /home/me/anaconda3/envs
                          /home/me/.conda/envs
               platform : linux-64
             user-agent : conda/4.4.7 requests/2.18.4 CPython/3.6.2 Linux/4.4.0-112-generic ubuntu/16.04 glibc/2.23
                UID:GID : 1001:1001
             netrc file : None
           offline mode : False
```
</p></details>


Discussion:
For now I've just cloned the base environment and put an `activate` command in my shell rc file
What shell are you using, and what version is it?

Can you give me the output of `echo $PATH` after `conda activate base` and `conda activate other-environment`?
zsh 5.1.1

I have just noticed that the issue only shows up within tmux — a "bare" terminal works ok but in tmux the base environment (only) doesn't activate properly.

this is `PATH` after `conda activate base` in tmux:
```
/home/me/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/me/.config/nvim/dein/repos/github.com/junegunn/fzf/bin:/home/me/texlive/2016/bin/x86_64-linux:/home/me/work/tools/bin:/usr/local/cuda/bin:/home/me/.hugh/vimfiles/dein/repos/github.com/junegunn/fzf/bin
```
and after `conda activate other-environment`:
```
/home/me/anaconda3/envs/other-environment/bin:/home/me/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/me/.config/nvim/dein/repos/github.com/junegunn/fzf/bin:/home/me/texlive/2016/bin/x86_64-linux:/home/me/work/tools/bin:/usr/local/cuda/bin:/home/me/.hugh/vimfiles/dein/repos/github.com/junegunn/fzf/bin
```
and after `conda activate base` outside tmux (which works as it should):
```
/home/me/anaconda3/bin:/home/me/anaconda3/envs/hugh/bin:/home/me/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/me/.config/nvim/dein/repos/github.com/junegunn/fzf/bin:/home/me/texlive/2016/bin/x86_64-linux:/home/me/work/tools/bin:/usr/local/cuda/bin:/home/me/.hugh/vimfiles/dein/repos/github.com/junegunn/fzf/bin
```
As part of `conda activate`, `source activate`, etc, we need to run `rehash` or `hash -r` to reset the shell's cache for stuff found on PATH.  Is that perhaps what's not working correctly in tmux for some reason?
Scratch that. PATH is clearly not correct in your example above for tmux.
Can you do the following and see what we get...

1. open clean, new shell under tmux
2. `echo $PATH`
3. `type -a conda`
4. `conda shell.posix activate base`  # won't actually activate; just show you what should be eval'd by the shell
5. `set -x`
6. `conda activate base`
This is from a new shell, with `base` activated

`echo $PATH`:
```
/home/me/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/me/.config/nvim/dein/repos/github.com/junegunn/fzf/bin:/home/me/texlive/2016/bin/x86_64-linux:/home/me/work/tools/bin:/usr/local/cuda/bin:/home/me/.hugh/vimfiles/dein/repos/github.com/junegunn/fzf/bin
```
`type -a conda`:
```
conda is a shell function from /home/me/anaconda3/etc/profile.d/conda.sh
```
`conda shell.posix activate base`:
```
export CONDA_PROMPT_MODIFIER='(base) '
export CONDA_SHLVL='1'
```
`set -x`
```
+omz_termsupport_preexec:1> emulate -L zsh
+omz_termsupport_preexec:2> setopt extended_glob
+omz_termsupport_preexec:4> [[ '' == true ]]
+omz_termsupport_preexec:9> local CMD=set
+omz_termsupport_preexec:10> local LINE='set -x'
+omz_termsupport_preexec:12> title '$CMD' '%100>...>$LINE%<<'
+title:1> emulate -L zsh
+title:2> setopt prompt_subst
+title:4> [[ '' == *term* ]]
+title:8> : '%100>...>$LINE%<<'
+title:10> case screen-256color (cygwin | xterm* | putty* | rxvt* | ansi)
+title:10> case screen-256color (screen*)
+title:16> print -Pn '\ek\$CMD\e\'
+prompt_geometry_set_cmd_title:1> prompt_geometry_print_title 'set -x @ %m'
+prompt_geometry_print_title:1> print -n '\e]0;'
+-zsh:15> set -x
+omz_termsupport_precmd:1> emulate -L zsh
+omz_termsupport_precmd:3> [[ '' == true ]]
+omz_termsupport_precmd:7> title '%15<..<%~%<<' '%n@%m: %~'
+title:1> emulate -L zsh
+title:2> setopt prompt_subst
+title:4> [[ '' == *term* ]]
+title:8> : '%n@%m: %~'
+title:10> case screen-256color (cygwin | xterm* | putty* | rxvt* | ansi)
+title:10> case screen-256color (screen*)
+title:16> print -Pn '\ek%15\<..\<%~%\<\<\e\'
+prompt_geometry_set_title:1> prompt_geometry_print_title '%~'
+prompt_geometry_print_title:1> print -n '\e]0;'
+prompt_geometry_render:1> [ 0 -eq 0 ']'
+prompt_geometry_render:2> PROMPT_SYMBOL=▲
+prompt_geometry_render:7> PROMPT='
 %F{blue}%3~%f
 %1{%(?.%F{white}▲%f.%F{magenta}△%f)%} '
+prompt_geometry_render:11> PROMPT2=' ◇ '
+prompt_geometry_render:12> RPROMPT=+prompt_geometry_render:12> echotc UP 1
+prompt_geometry_render:12> RPROMPT=+prompt_geometry_render:12> prompt_hugh_conda_env_info
+prompt_hugh_conda_env_info:1> env_name=base
+prompt_hugh_conda_env_info:2> [ base '!=' root ']'
+prompt_hugh_conda_env_info:2> [ base '!=' '' ']'
+prompt_hugh_conda_env_info:3> git rev-parse --git-dir
+prompt_hugh_conda_env_info:6> prompt_geometry_colorize 242 base
+prompt_geometry_colorize:1> echo '%F{242}base%f'
+prompt_hugh_conda_env_info:6> echo '%F{242}base%f'
+prompt_geometry_render:12> RPROMPT=+prompt_geometry_render:12>
prompt_geometry_git_info
+prompt_geometry_git_info:1> git rev-parse --git-dir
+prompt_geometry_render:12> RPROMPT=+pr%}%F{242}base%f%f%{r:12> echotc DO 1
+prompt_geometry_render:12> RPROMPT='%{                   %}'
```
`conda activate base`:
```
+omz_termsupport_preexec:1> emulate -L zsh
+omz_termsupport_preexec:2> setopt extended_glob
+omz_termsupport_preexec:4> [[ '' == true ]]
+omz_termsupport_preexec:9> local CMD=conda
+omz_termsupport_preexec:10> local LINE='conda activate base'
+omz_termsupport_preexec:12> title '$CMD' '%100>...>$LINE%<<'
+title:1> emulate -L zsh
+title:2> setopt prompt_subst
+title:4> [[ '' == *term* ]]
+title:8> : '%100>...>$LINE%<<'
+title:10> case screen-256color (cygwin | xterm* | putty* | rxvt* | ansi)
+title:10> case screen-256color (screen*)
+title:16> print -Pn '\ek\$CMD\e\'
+prompt_geometry_set_cmd_title:1> prompt_geometry_print_title 'conda activate base @ %m'
+prompt_geometry_print_title:1> print -n '\e]0;'
+-zsh:16> conda activate base
+conda:1> [ 2 -ge 1 ']'
+conda:2> local cmd=activate
+conda:3> shift
+conda:7> case activate (activate)
+conda:9> _conda_activate base
+_conda_activate:1> [ -n '' ']'
+_conda_activate:8> local ask_conda
+_conda_activate:9> ask_conda=+_conda_activate:9> PS1='
 %F{blue}%3~%f
 %1{%(?.%F{white}▲%f.%F{magenta}△%f)%} ' /home/me/anaconda3/bin/conda
shell.posix activate base
+_conda_activate:9> ask_conda='export CONDA_PROMPT_MODIFIER='\''(base) '\''
export CONDA_SHLVL='\''1'\'
+_conda_activate:10> eval 'export CONDA_PROMPT_MODIFIER='\''(base) '\''
export CONDA_SHLVL='\''1'\'
+(eval):1> export CONDA_PROMPT_MODIFIER='(base) '
+(eval):2> export CONDA_SHLVL=1
+_conda_activate:12> _conda_hashr
+_conda_hashr:1> case zsh (zsh)
+_conda_hashr:2> rehash
+omz_termsupport_precmd:1> emulate -L zsh
+omz_termsupport_precmd:3> [[ '' == true ]]
+omz_termsupport_precmd:7> title '%15<..<%~%<<' '%n@%m: %~'
+title:1> emulate -L zsh
+title:2> setopt prompt_subst
+title:4> [[ '' == *term* ]]
+title:8> : '%n@%m: %~'
+title:10> case screen-256color (cygwin | xterm* | putty* | rxvt* | ansi)
+title:10> case screen-256color (screen*)
+title:16> print -Pn '\ek%15\<..\<%~%\<\<\e\'
+prompt_geometry_set_title:1> prompt_geometry_print_title '%~'
+prompt_geometry_print_title:1> print -n '\e]0;'
+prompt_geometry_render:1> [ 0 -eq 0 ']'
+prompt_geometry_render:2> PROMPT_SYMBOL=▲
+prompt_geometry_render:7> PROMPT='
 %F{blue}%3~%f
 %1{%(?.%F{white}▲%f.%F{magenta}△%f)%} '
+prompt_geometry_render:11> PROMPT2=' ◇ '
+prompt_geometry_render:12> RPROMPT=+prompt_geometry_render:12> echotc UP
1
+prompt_geometry_render:12> RPROMPT=+prompt_geometry_render:12>
prompt_hugh_conda_env_info
+prompt_hugh_conda_env_info:1> env_name=base
+prompt_hugh_conda_env_info:2> [ base '!=' root ']'
+prompt_hugh_conda_env_info:2> [ base '!=' '' ']'
+prompt_hugh_conda_env_info:3> git rev-parse --git-dir
+prompt_hugh_conda_env_info:6> prompt_geometry_colorize 242 base
+prompt_geometry_colorize:1> echo '%F{242}base%f'
+prompt_hugh_conda_env_info:6> echo '%F{242}base%f'
+prompt_geometry_render:12> RPROMPT=+prompt_geometry_render:12>
prompt_geometry_git_info
+prompt_geometry_git_info:1> git rev-parse --git-dir
+prompt_geometry_render:12> RPROMPT=+pr%}%F{242}base%f%f%{r:12> echotc DO
1
+prompt_geometry_render:12> RPROMPT='%{                   %}'
```

there's lots of zsh prompt stuff in there, but it just looks like there's no path setting command at all for some reason...
Also, and this is a bit odd, tmux seems to activate the base environment even though I removed the `conda activate base` command from my zshrc
A bare shell doesn't activate anything, but as soon as I load tmux I get the `base` prompt showing up
That last comment seems to be part of the problem: if I load tmux, and _deactivate_ the `base` environment (so there's no environment active), then `conda shell.posix activate base` looks good, and `conda activate base` alters the path as expected

So for some reason tmux is improperly activating the base environment when it starts
Ok problem starts with

`conda shell.posix activate base`:
```
export CONDA_PROMPT_MODIFIER='(base) '
export CONDA_SHLVL='1'
```

So, one more request for information...

1. open clean, new shell under tmux
2. `env | sort`
3. `conda shell.posix activate base`
As I said, this is starting tmux without any `conda activate` anything in my zshrc. 
`env | sort`:
```BROWSER=google-chrome
CLUTTER_IM_MODULE=xim
CONDA_DEFAULT_ENV=base
CONDA_PREFIX=/home/me/anaconda3
CONDA_PROMPT_MODIFIER=(base) 
CONDA_PYTHON_EXE=/home/me/anaconda3/bin/python
CONDA_SHLVL=1
CPATH=/home/me/cuda/include:/home/me/cuda/include:
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-hxf9qZRlyl
DEFAULTS_PATH=/usr/share/gconf/gnome.default.path
DESKTOP_MODE=1
DESKTOP_SESSION=gnome
DISPLAY=:0
EDITOR=nvim
EVENT_NOEPOLL=1
FZF_ALT_C_COMMAND=find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune -o -type d -name -print 2> /dev/null | sed 1d | cut -b3-
FZF_CTRL_T_COMMAND=find -L . \( -fstype 'dev' -o -fstype 'proc' \) -prune -o -type f -print -o -type d -print -o -type l -print 2> /dev/null | sed 1d | cut -b3-
FZF_DEFAULT_COMMAND=ag -l --hidden -g ""
GDM_LANG=en_GB
GDMSESSION=gnome
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
GNOME_KEYRING_CONTROL=
GNOME_KEYRING_PID=
GPG_AGENT_INFO=/home/me/.gnupg/S.gpg-agent:0:1
GTK2_MODULES=overlay-scrollbar
GTK_IM_MODULE=ibus
GTK_MODULES=gail:atk-bridge
HOME=/home/me
IM_CONFIG_PHASE=1
INSTANCE=GNOME
JOB=gnome-session
KEYTIMEOUT=1
LANG=en_GB.UTF-8
LANGUAGE=en_GB:en
LC_CTYPE=en_GB.UTF-8
LD_LIBRARY_PATH=/usr/local/cuda/lib64:/home/me/cuda/lib64:/usr/local/cuda/lib64:/home/me/cuda/lib64:
LESS=-R
LIBRARY_PATH=/usr/local/cuda/lib64:/home/me/cuda/lib64:/usr/local/cuda/lib64:/home/me/cuda/lib64:
LIBVIRT_DEFAULT_URI=qemu:///system
LOGNAME=me
LSCOLORS=Gxfxcxdxbxegedabagacad
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path
MYZSH=/home/me/.hugh/general
NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
OLDPWD=/home/me
PAGER=less
PAM_KWALLET5_LOGIN=/tmp/kwallet5_me.socket
PATH=/home/me/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/me/.config/nvim/dein/repos/github.com/junegunn/fzf/bin:/home/me/texlive/2016/bin/x86_64-linux:/home/me/work/tools/bin:/usr/local/cuda/bin:/home/me/.hugh/vimfiles/dein/repos/github.com/junegunn/fzf/bin
PWD=/home/me
QT4_IM_MODULE=xim
QT_ACCESSIBILITY=1
QT_IM_MODULE=ibus
QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1
QT_QPA_PLATFORMTHEME=appmenu-qt5
SESSIONTYPE=gnome-session
SHELL=/usr/bin/zsh
SHLVL=2
SSH_AUTH_SOCK=/run/user/1001/keyring/ssh
TERM=screen-256color
TMUX_PANE=%30
TMUX=/tmp/tmux-1001/default,16045,7
UPDATE_ZSH_DAYS=7
UPSTART_EVENTS=started starting
UPSTART_INSTANCE=
UPSTART_JOB=gnome-settings-daemon
UPSTART_SESSION=unix:abstract=/com/ubuntu/upstart-session/1001/2610
USER=me
_=/usr/bin/env
VTE_VERSION=4205
WINDOWID=67170133
XAUTHORITY=/home/me/.Xauthority
XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/usr/share/upstart/xdg:/etc/xdg
XDG_CURRENT_DESKTOP=GNOME
XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share:/usr/share:/var/lib/snapd/desktop:/var/lib/snapd/desktop
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/me
XDG_RUNTIME_DIR=/run/user/1001
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
XDG_SEAT=seat0
XDG_SESSION_DESKTOP=gnome
XDG_SESSION_ID=c2
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SESSION_TYPE=x11
XDG_VTNR=7
XMODIFIERS=@im=ibus
ZSH=/home/me/.oh-my-zsh
```
`conda shell.posix activate base`:
```
export CONDA_PROMPT_MODIFIER='(base) '
export CONDA_SHLVL='1'
```
Ok so the `CONDA_` environment variables you have there... all of those are indicating that you have your base env activated. Which is the case before you start tmux. After you start tmux, you’re carrying over some of those environment variables, but also doing something to PATH. Probably resetting it to a hardcoded value that doesn’t respect previous state. 
I thought that, so I tried starting tmux without any env activated and it stayed the same...
Haha well those `CONDA_` environment variables aren’t going to set themselves ¯\\\_(ツ)\_/¯ 
Ok, so that last comment was because I had a tmux session left running. I stopped every tmux session, started a fresh shell with base env active, and now when I run tmux I get the problem. It seems that tmux holds the environment variables over, so the new shell isn't "bare" when `conda activate base` is encountered in .zshrc
`env | sort`:
```
BROWSER=google-chrome
CLUTTER_IM_MODULE=xim
CONDA_DEFAULT_ENV=base
CONDA_PREFIX=/home/me/anaconda3
CONDA_PROMPT_MODIFIER=(base) 
CONDA_PYTHON_EXE=/home/me/anaconda3/bin/python
CONDA_SHLVL=1
CPATH=/home/me/cuda/include:/home/me/cuda/include:
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-zGJ7TsNLxt
DEFAULTS_PATH=/usr/share/gconf/gnome.default.path
DESKTOP_MODE=1
DESKTOP_SESSION=gnome
DISPLAY=:0
EDITOR=nvim
EVENT_NOEPOLL=1
FZF_ALT_C_COMMAND=find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune -o -type d -name -print 2> /dev/null | sed 1d | cut -b3-
FZF_CTRL_T_COMMAND=find -L . \( -fstype 'dev' -o -fstype 'proc' \) -prune -o -type f -print -o -type d -print -o -type l -print 2> /dev/null | sed 1d | cut -b3-
FZF_DEFAULT_COMMAND=ag -l --hidden -g ""
GDM_LANG=en_GB
GDMSESSION=gnome
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
GNOME_KEYRING_CONTROL=
GNOME_KEYRING_PID=
GPG_AGENT_INFO=/home/me/.gnupg/S.gpg-agent:0:1
GTK2_MODULES=overlay-scrollbar
GTK_IM_MODULE=ibus
GTK_MODULES=gail:atk-bridge
HOME=/home/me
IM_CONFIG_PHASE=1
INSTANCE=GNOME
JOB=gnome-session
KEYTIMEOUT=1
LANG=en_GB.UTF-8
LANGUAGE=en_GB:en
LC_CTYPE=en_GB.UTF-8
LD_LIBRARY_PATH=/usr/local/cuda/lib64:/home/me/cuda/lib64:/usr/local/cuda/lib64:/home/me/cuda/lib64:
LESS=-R
LIBRARY_PATH=/usr/local/cuda/lib64:/home/me/cuda/lib64:/usr/local/cuda/lib64:/home/me/cuda/lib64:
LIBVIRT_DEFAULT_URI=qemu:///system
LOGNAME=me
LSCOLORS=Gxfxcxdxbxegedabagacad
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path
MYZSH=/home/me/.hugh/general
NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
OLDPWD=/home/me
PAGER=less
PAM_KWALLET5_LOGIN=/tmp/kwallet5_me.socket
PATH=/home/me/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/me/.config/nvim/dein/repos/github.com/junegunn/fzf/bin:/home/me/texlive/2016/bin/x86_64-linux:/home/me/work/tools/bin:/usr/local/cuda/bin:/home/me/.hugh/vimfiles/dein/repos/github.com/junegunn/fzf/bin
PWD=/home/me
QT4_IM_MODULE=xim
QT_ACCESSIBILITY=1
QT_IM_MODULE=ibus
QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1
QT_QPA_PLATFORMTHEME=appmenu-qt5
SESSIONTYPE=gnome-session
SHELL=/usr/bin/zsh
SHLVL=2
SSH_AUTH_SOCK=/run/user/1001/keyring/ssh
TERM=screen-256color
TMUX_PANE=%13
TMUX=/tmp/tmux-1001/default,5914,1
UPDATE_ZSH_DAYS=7
UPSTART_EVENTS=started starting
UPSTART_INSTANCE=
UPSTART_JOB=gnome-settings-daemon
UPSTART_SESSION=unix:abstract=/com/ubuntu/upstart-session/1001/2794
USER=me
_=/usr/bin/env
VTE_VERSION=4205
WINDOWID=54531185
XAUTHORITY=/home/me/.Xauthority
XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/usr/share/upstart/xdg:/etc/xdg
XDG_CURRENT_DESKTOP=GNOME
XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share:/usr/share:/var/lib/snapd/desktop:/var/lib/snapd/desktop
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/me
XDG_RUNTIME_DIR=/run/user/1001
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
XDG_SEAT=seat0
XDG_SESSION_DESKTOP=gnome
XDG_SESSION_ID=c2
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SESSION_TYPE=x11
XDG_VTNR=7
XMODIFIERS=@im=ibus
ZSH=/home/me/.oh-my-zsh
```
`conda shell.posix activate base`:
```
export CONDA_PROMPT_MODIFIER='(base) '
export CONDA_SHLVL='1'
```
For now I've added a check in `.zshrc`, if it detects that the shell is running in tmux then it does a `conda deactivate` before the `conda activate base` line. That works fine, I'm happy enough with the results

Resolving patch:
diff --git a/conda/activate.py b/conda/activate.py
--- a/conda/activate.py
+++ b/conda/activate.py
@@ -361,11 +361,16 @@ def build_reactivate(self):
                 'activate_scripts': (),
             }
         conda_default_env = self.environ.get('CONDA_DEFAULT_ENV', self._default_env(conda_prefix))
+        new_path = self.pathsep_join(self._replace_prefix_in_path(conda_prefix, conda_prefix))
+        set_vars = {}
+        conda_prompt_modifier = self._prompt_modifier(conda_default_env)
+        self._update_prompt(set_vars, conda_prompt_modifier)
         # environment variables are set only to aid transition from conda 4.3 to conda 4.4
         return {
             'unset_vars': (),
-            'set_vars': {},
+            'set_vars': set_vars,
             'export_vars': {
+                'PATH': new_path,
                 'CONDA_SHLVL': conda_shlvl,
                 'CONDA_PROMPT_MODIFIER': self._prompt_modifier(conda_default_env),
             },


Test patch:
diff --git a/tests/test_activate.py b/tests/test_activate.py
--- a/tests/test_activate.py
+++ b/tests/test_activate.py
@@ -295,14 +295,23 @@ def test_activate_same_environment(self):
             with env_var('CONDA_SHLVL', '1'):
                 with env_var('CONDA_PREFIX', old_prefix):
                     activator = Activator('posix')
+
                     builder = activator.build_activate(td)
 
+                    new_path_parts = activator._replace_prefix_in_path(old_prefix, old_prefix)
+                    conda_prompt_modifier = "(%s) " % old_prefix
+                    ps1 = conda_prompt_modifier + os.environ.get('PS1', '')
+
+                    set_vars = {
+                        'PS1': ps1,
+                    }
                     export_vars = {
+                        'PATH': activator.pathsep_join(new_path_parts),
                         'CONDA_PROMPT_MODIFIER': "(%s) " % td,
                         'CONDA_SHLVL': 1,
                     }
                     assert builder['unset_vars'] == ()
-                    assert builder['set_vars'] == {}
+                    assert builder['set_vars'] == set_vars
                     assert builder['export_vars'] == export_vars
                     assert builder['activate_scripts'] == (activator.path_conversion(activate_d_1),)
                     assert builder['deactivate_scripts'] == (activator.path_conversion(deactivate_d_1),)
@@ -478,15 +487,20 @@ def test_posix_basic(self):
             assert rc == 0
             reactivate_data = c.stdout
 
+            new_path_parts = activator._replace_prefix_in_path(self.prefix, self.prefix)
             assert reactivate_data == dals("""
             . "%(deactivate1)s"
+            PS1='%(ps1)s'
             export CONDA_PROMPT_MODIFIER='(%(native_prefix)s) '
             export CONDA_SHLVL='1'
+            export PATH='%(new_path)s'
             . "%(activate1)s"
             """) % {
                 'activate1': activator.path_conversion(join(self.prefix, 'etc', 'conda', 'activate.d', 'activate1.sh')),
                 'deactivate1': activator.path_conversion(join(self.prefix, 'etc', 'conda', 'deactivate.d', 'deactivate1.sh')),
                 'native_prefix': self.prefix,
+                'new_path': activator.pathsep_join(new_path_parts),
+                'ps1': '(%s) ' % self.prefix + os.environ.get('PS1', ''),
             }
 
             with captured() as c:
@@ -560,15 +574,18 @@ def test_cmd_exe_basic(self):
                 reactivate_data = fh.read()
             rm_rf(reactivate_result)
 
+            new_path_parts = activator._replace_prefix_in_path(self.prefix, self.prefix)
             assert reactivate_data == dals("""
             @CALL "%(deactivate1)s"
             @SET "CONDA_PROMPT_MODIFIER=(%(native_prefix)s) "
             @SET "CONDA_SHLVL=1"
+            @SET "PATH=%(new_path)s"
             @CALL "%(activate1)s"
             """) % {
                 'activate1': activator.path_conversion(join(self.prefix, 'etc', 'conda', 'activate.d', 'activate1.bat')),
                 'deactivate1': activator.path_conversion(join(self.prefix, 'etc', 'conda', 'deactivate.d', 'deactivate1.bat')),
                 'native_prefix': self.prefix,
+                'new_path': activator.pathsep_join(new_path_parts),
             }
 
             with captured() as c:
@@ -635,12 +652,17 @@ def test_csh_basic(self):
             assert rc == 0
             reactivate_data = c.stdout
 
+            new_path_parts = activator._replace_prefix_in_path(self.prefix, self.prefix)
             assert reactivate_data == dals("""
             source "%(deactivate1)s";
+            set prompt='%(prompt)s';
             setenv CONDA_PROMPT_MODIFIER "(%(native_prefix)s) ";
             setenv CONDA_SHLVL "1";
+            setenv PATH "%(new_path)s";
             source "%(activate1)s";
             """) % {
+                'prompt': '(%s) ' % self.prefix + os.environ.get('prompt', ''),
+                'new_path': activator.pathsep_join(new_path_parts),
                 'activate1': activator.path_conversion(join(self.prefix, 'etc', 'conda', 'activate.d', 'activate1.csh')),
                 'deactivate1': activator.path_conversion(join(self.prefix, 'etc', 'conda', 'deactivate.d', 'deactivate1.csh')),
                 'native_prefix': self.prefix,
@@ -714,15 +736,18 @@ def test_xonsh_basic(self):
                 reactivate_data = fh.read()
             rm_rf(reactivate_result)
 
+            new_path_parts = activator._replace_prefix_in_path(self.prefix, self.prefix)
             assert reactivate_data == dals("""
             source "%(deactivate1)s"
             $CONDA_PROMPT_MODIFIER = '(%(native_prefix)s) '
             $CONDA_SHLVL = '1'
+            $PATH = '%(new_path)s'
             source "%(activate1)s"
             """) % {
                 'activate1': activator.path_conversion(join(self.prefix, 'etc', 'conda', 'activate.d', 'activate1.xsh')),
                 'deactivate1': activator.path_conversion(join(self.prefix, 'etc', 'conda', 'deactivate.d', 'deactivate1.xsh')),
                 'native_prefix': self.prefix,
+                'new_path': activator.pathsep_join(new_path_parts),
             }
 
             with captured() as c:
@@ -787,12 +812,15 @@ def test_fish_basic(self):
             assert rc == 0
             reactivate_data = c.stdout
 
+            new_path_parts = activator._replace_prefix_in_path(self.prefix, self.prefix)
             assert reactivate_data == dals("""
             source "%(deactivate1)s";
             set -gx CONDA_PROMPT_MODIFIER "(%(native_prefix)s) ";
             set -gx CONDA_SHLVL "1";
+            set -gx PATH "%(new_path)s";
             source "%(activate1)s";
             """) % {
+                'new_path': activator.pathsep_join(new_path_parts),
                 'activate1': activator.path_conversion(join(self.prefix, 'etc', 'conda', 'activate.d', 'activate1.fish')),
                 'deactivate1': activator.path_conversion(join(self.prefix, 'etc', 'conda', 'deactivate.d', 'deactivate1.fish')),
                 'native_prefix': self.prefix,
@@ -857,15 +885,18 @@ def test_powershell_basic(self):
             assert rc == 0
             reactivate_data = c.stdout
 
+            new_path_parts = activator._replace_prefix_in_path(self.prefix, self.prefix)
             assert reactivate_data == dals("""
             . "%(deactivate1)s"
             $env:CONDA_PROMPT_MODIFIER = "(%(prefix)s) "
             $env:CONDA_SHLVL = "1"
+            $env:PATH = "%(new_path)s"
             . "%(activate1)s"
             """) % {
                 'activate1': join(self.prefix, 'etc', 'conda', 'activate.d', 'activate1.ps1'),
                 'deactivate1': join(self.prefix, 'etc', 'conda', 'deactivate.d', 'deactivate1.ps1'),
                 'prefix': self.prefix,
+                'new_path': activator.pathsep_join(new_path_parts),
             }
 
             with captured() as c: