condamambamicromamba

How to use only the channels specified explicitly in the conda environment.yaml


I've noticed that when creating a conda environment from an environment.yaml file that explicitly specifies channels, conda (and also mamba) seems to extend the list of channels with whatever is defined in .condarc/.mambarc.

This is surprising - after all the key is channels not additional_channels.

Is there some way to make conda/mamba ignore the "default" channels configured outside of the environment file in question?

To be concrete, here's a minimal reproducible example.

My .condarc/.mambarc look like this:

channels:
- conda-forge
- bioconda

yet I want bioconda to be entirely ignored when installing the following environment.yaml:

name: testenv
channels:
- conda-forge
dependencies:
- python

Solution

  • The solution is to add the magic nodefaults channel to the channel list:

    name: testenv
    channels:
    - conda-forge
    - nodefaults  # adding this is the solution
    dependencies:
    - python
    

    Another less ideal option is to pass the --override-channels CLI flag when creating the environment.

    conda create -n testenv -f testenv.yaml --override-channels
    

    I tried adding both override_channels: true and override-channels: true to the environment spec, but that didn't have any effect.

    Thanks to @merv for pointing out the workaround in this Github issue