It's mostly convenience - i.e., the conda install
command is sufficiently expressive to specify any channel prioritization. For example, one can specify the recommended Bioconda channel priorities manually at each install:
conda install -n metagenomics_env --override-channels -c conda-forge -c bioconda -c defaults kraken
but setting it on a per-env basis let's one set and forget
conda activate metagenomics_env
conda config --env --add channels defaults
conda config --env --add channels bioconda
conda config --env --add channels conda-forge
...
conda install -n metagenomics_env kraken
This can be quite helpful when one has a diversity of projects that aren't conducive to having a single, global channel prioritization.
One issue that one should be aware of is that running conda env export
always results in exporting the global channel configuration. While build IDs are included in the environment.yml
, and are usually sufficiently distinct to capture channel of origin, if the channel isn't in the global channels
configuration, then the builds won't be found if the system recreating the env doesn't have that channel in their config.
Additional Uses
It is also worth emphasizing that the --env
flag enables every config option to be set on an env-specific basis, not just channels. This can be useful for some edge cases, such as specifying a subdir constraint (e.g., win-32 vs win-64) or enabling experimental features like pip_interop_enabled
only in specific envs.