Search code examples
github-actionscondamamba

mamba install fails on github actions


Installing mamba in a GitHub action with conda install -y -c conda-forge mamba fails with: Found conflicts! Looking for incompatible packages. followed by a long list of conflicts, see log

My workflow file is quite simple, here is the relevant portion:

...
    runs-on: ubuntu-latest
    timeout-minutes: 60
    strategy:
      fail-fast: false
      matrix:
        python-version: [3.7, 3.8, 3.9, '3.10', 3.11, 3]

    steps:
      - uses: actions/checkout@v2

      - name: Install system dependencies
        run: sudo apt-get update && sudo apt-get -y --no-install-recommends install -y ghostscript

      - uses: conda-incubator/setup-miniconda@v2
        with:
          auto-update-conda: false
          python-version: ${{ matrix.python-version }}
          use-only-tar-bz2: true
          #mamba-version: "*"

      - name: Install mamba
        run: conda install -y -c conda-forge mamba
...

I am aware I can install mamba with miniconda within setup-miniconda, but this also failed with conflicts.

I'd imagine mamba on github-actions is a very common combination, so I must be doing something wrong?


Solution

  • Use Miniforge

    It is no longer recommended to use Miniconda + Mamba, and there is an incompatibility with installing Mamba into an environment with Miniconda base. Instead, go straight to Miniforge (which now includes Mamba):

      - uses: conda-incubator/setup-miniconda@v2
        with:
          auto-update-conda: false
          python-version: ${{ matrix.python-version }}
          use-only-tar-bz2: true
          miniforge-version: latest
    

    If subsequent steps in the GitHub workflow specifically depend on the mamba command being there (e.g., Snakemake), then this makes sense. Otherwise, if you to instantiate an environment, I would strongly recommend using Micromamba instead.

    Use Micromamba (preferred for CI)

    Installing a full Conda base in CI is usually unnecessary and state-of-the-art for DevOps needing a Conda environment is to use Micromamba. This is a minimal static binary that does Conda environment and package management. For GHA's, there is the mamba-org/setup-micromamba action.

    In this case, one simply defines what is needed in the environment through a YAML, and Micromamba will create it and configure the activations so that subsequent shell processes can use it.