How does conda-env list / conda info --envs find environments?

16,518

The code for the info command is contained in the cli.main_info module, and the relevant code for this case is here. This imports the function from over here that (among other things) reads the configuration value envs_dirs. You can find out the value of this configuration value on your system by running

conda config --show envs_dirs

I expect this will show you the user directories for environments as being searched.

Share:
16,518
pgoetz
Author by

pgoetz

Updated on June 24, 2022

Comments

  • pgoetz
    pgoetz almost 2 years

    I've been experimenting with anaconda/miniconda because my users use structural biology programs installed with miniconda and none of the authors A) take into account that there might be other miniconda applications B) that their programs will be used in a multi-user environment.

    So, using Arch linux, first I installed anaconda (version 4.5.12) , and then using my own account, created a couple of test environments:

    conda create -n snakes
    conda create -n sharks
    

    I then (completely) uninstalled anaconda and installed miniconda (also version 4.5.12) and then created another environment in a non-standard location as root:

    # conda create -p /usr/local/miniconda/pyem
    

    Here's where things get weird. When I list the environments as the root user, I see not only the default and the one I just created, but also the ones I created previously using my user account!

    [root@lizard /]# conda info --envs
    # conda environments:
    #
                             /home/cnsit/.conda/envs/sharks
                             /home/cnsit/.conda/envs/snakes
    base                  *  /opt/miniconda3
                             /usr/local/miniconda/pyem
    

    (The conda-env list command gives the same output.)

    So, question: how is conda finding environments created by a different user? Moreover, when the entire parent directory of the original instance of conda has been removed and replaced by one in an entirely different location (so no local environments.txt file could be cataloging this.

  • pgoetz
    pgoetz over 5 years
    Thanks. The only remaining question is how to properly change envs_dirs.
  • darthbith
    darthbith over 5 years
    conda config --add/--remove/--append envs_dirs dir_name. But some of it may be built in. Is there a problem with showing all the environments?
  • pgoetz
    pgoetz over 5 years
    No, they show up when I run the command you posted. It just appears that by default conda is designed for single user use, and I have to set up some applications in a multi-user environment accessible from an NFS=-mounted filesystem, so I was looking into moving things around a bit and putting these conda environments in, for example, /usr/local/miniconda.
  • darthbith
    darthbith over 5 years
    You could definitely do that, you can put a config file (I forget the name right now) either in each user's home directory or in a system location to add envs_dirs to be searched
  • pgoetz
    pgoetz over 5 years