# Buggy code
def _get_starting_path_list(self):
    path = self.environ["PATH"]
    if on_win:
        # On Windows, the Anaconda Python interpreter prepends sys.prefix\Library\bin on
        # startup. It's a hack that allows users to avoid using the correct activation
        # procedure; a hack that needs to go away because it doesn't add all the paths.
        # See: https://github.com/AnacondaRecipes/python-feedstock/blob/master/recipe/0005-Win32-Ensure-Library-bin-is-in-os.environ-PATH.patch  # NOQA
        # But, we now detect if that has happened because:
        #   1. In future we would like to remove this hack and require real activation.
        #   2. We should not assume that the Anaconda Python interpreter is being used.
        path_split = path.split(os.pathsep)
        library_bin = r"%s\Library\bin" % (sys.prefix)
        # ^^^ deliberately the same as: https://github.com/AnacondaRecipes/python-feedstock/blob/8e8aee4e2f4141ecfab082776a00b374c62bb6d6/recipe/0005-Win32-Ensure-Library-bin-is-in-os.environ-PATH.patch#L20  # NOQA
        if paths_equal(path_split[0], library_bin):
            return path_split[1:]
        else:
            return path_split
    else:
        return path.split(os.pathsep)


# Traceback (KeyError)
$ env -i bash --norc --noprofile
bash-4.1$ /path/to/conda/anaconda3/bin/conda shell.posix activate

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

Traceback (most recent call last):
File "/group_workspaces/cems2/fiduceo/Users/gholl/anaconda3/lib/python3.6/site-packages/conda/cli/main.py", line 98, in main
return activator_main()
File "/group_workspaces/cems2/fiduceo/Users/gholl/anaconda3/lib/python3.6/site-packages/conda/activate.py", line 584, in main
print(activator.execute(), end='')
File "/group_workspaces/cems2/fiduceo/Users/gholl/anaconda3/lib/python3.6/site-packages/conda/activate.py", line 157, in execute
return getattr(self, self.command)()
File "/group_workspaces/cems2/fiduceo/Users/gholl/anaconda3/lib/python3.6/site-packages/conda/activate.py", line 143, in activate
return self._finalize(self._yield_commands(self.build_activate(self.env_name_or_prefix)),
File "/group_workspaces/cems2/fiduceo/Users/gholl/anaconda3/lib/python3.6/site-packages/conda/activate.py", line 244, in build_activate
new_path = self.pathsep_join(self._add_prefix_to_path(prefix))
File "/group_workspaces/cems2/fiduceo/Users/gholl/anaconda3/lib/python3.6/site-packages/conda/activate.py", line 417, in _add_prefix_to_path
starting_path_dirs = self._get_starting_path_list()
File "/group_workspaces/cems2/fiduceo/Users/gholl/anaconda3/lib/python3.6/site-packages/conda/activate.py", line 384, in _get_starting_path_list
path = self.environ['PATH']
KeyError: 'PATH'

`$ /group_workspaces/cems2/fiduceo/Users/gholl/anaconda3/bin/conda shell.posix activate`

environment variables:
CIO_TEST=<not set>
CONDA_ROOT=/group_workspaces/cems2/fiduceo/Users/gholl/anaconda3
REQUESTS_CA_BUNDLE=<not set>
SSL_CERT_FILE=<not set>

active environment : None
user config file : /home/users/gholl/.condarc
populated config files : /home/users/gholl/.condarc
conda version : 4.5.4
conda-build version : 3.0.27
python version : 3.6.3.final.0
base environment : /group_workspaces/cems2/fiduceo/Users/gholl/anaconda3  (writable)
channel URLs : https://conda.anaconda.org/rttools/linux-64
https://conda.anaconda.org/rttools/noarch
https://conda.anaconda.org/conda-forge/linux-64
https://conda.anaconda.org/conda-forge/noarch
https://repo.anaconda.com/pkgs/main/linux-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/free/linux-64
https://repo.anaconda.com/pkgs/free/noarch
https://repo.anaconda.com/pkgs/r/linux-64
https://repo.anaconda.com/pkgs/r/noarch
https://repo.anaconda.com/pkgs/pro/linux-64
https://repo.anaconda.com/pkgs/pro/noarch
package cache : /group_workspaces/cems2/fiduceo/Users/gholl/anaconda3/pkgs
/home/users/gholl/.conda/pkgs
envs directories : /group_workspaces/cems2/fiduceo/Users/gholl/anaconda3/envs
/home/users/gholl/.conda/envs
platform : linux-64
user-agent : conda/4.5.4 requests/2.18.4 CPython/3.6.3 Linux/2.6.32-754.el6.x86_64 rhel/6.10 glibc/2.12
UID:GID : 35063:26030
netrc file : None
offline mode : False


An unexpected error has occurred. Conda has prepared the above report.
Upload successful.

# Fixed code
def _get_starting_path_list(self):
    path = self.environ.get("PATH", "")
    if on_win:
        # On Windows, the Anaconda Python interpreter prepends sys.prefix\Library\bin on
        # startup. It's a hack that allows users to avoid using the correct activation
        # procedure; a hack that needs to go away because it doesn't add all the paths.
        # See: https://github.com/AnacondaRecipes/python-feedstock/blob/master/recipe/0005-Win32-Ensure-Library-bin-is-in-os.environ-PATH.patch  # NOQA
        # But, we now detect if that has happened because:
        #   1. In future we would like to remove this hack and require real activation.
        #   2. We should not assume that the Anaconda Python interpreter is being used.
        path_split = path.split(os.pathsep)
        library_bin = r"%s\Library\bin" % (sys.prefix)
        # ^^^ deliberately the same as: https://github.com/AnacondaRecipes/python-feedstock/blob/8e8aee4e2f4141ecfab082776a00b374c62bb6d6/recipe/0005-Win32-Ensure-Library-bin-is-in-os.environ-PATH.patch#L20  # NOQA
        if paths_equal(path_split[0], library_bin):
            return path_split[1:]
        else:
            return path_split
    else:
        return path.split(os.pathsep)