The package upsetr was installed with conda. It **works** in my **terminal**

    conda activate upsetr
    conda deactivate

I was trying to invoke conda in a **Makefile** , something like

    SHELL=/bin/bash
    test:
          conda activate upsetr &&  conda deactivate

but it doesn't work:

    CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
    To initialize your shell, run
    
        $ conda init <SHELL_NAME>
    
    Currently supported shells are:

I can reproduce this error by piping the command into bash


    $ echo 'conda activate upsetr && conda deactivate' | bash
    
    CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
    To initialize your shell, run
    
        $ conda init <SHELL_NAME>


Why does it fail ?

I have learned quite a few techniques above, let me share what I do to avoid sourcing `.bashrc` on every system. There is another conda specific script at `~/miniconda3/etc/profile.d/conda.sh` that seems to be more appropriate for the purpose.

The shell script below runs in whatever environment you pass to it as a parameter and it sources the `conda.sh` script.


    # Conda prefix
    ENV=$1
    
    # Load conda specific commands.
    source ~/miniconda3/etc/profile.d/conda.sh
    
    # Activate the environment.
    conda activate $ENV
    
    # Print conda prefix
    echo PREFIX:$CONDA_PREFIX

of course, conda may choose to change the content of `conda.sh` at any time so we need to keep that in mind.