Activate a Conda Install Manually

I create a lot of independent Miniconda installs that I want to activate manually. Back in the day, you could just do this by putting $PREFIX/bin in $PATH, but things are different now. Namely:

eval "$(@PREFIX@/bin/conda shell.bash hook)"

with the super important note that the double quotes are essential!

For reference, here’s the shell script snippet that Conda wants to put in your .bashrc, as of Miniconda 4.6.14, with @PREFIX@ substituted as appropriate:

__conda_setup="$('@PREFIX@/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
    if [ -f "@PREFIX@/etc/profile.d/" ]; then
        . "@PREFIX@/etc/profile.d/"
        export PATH="@PREFIX@/bin:$PATH"
unset __conda_setup

(Apparently this comes from conda init somehow.)