conda-incubator / setup-miniconda

Set up your GitHub Actions workflow with conda via miniconda
https://github.com/marketplace/actions/setup-miniconda
MIT License
402 stars 68 forks source link

`defaults` channel in `.condarc` file when only `conda-forge` is specified #207

Open jrbourbeau opened 2 years ago

jrbourbeau commented 2 years ago

We're using setup-miniconda over in dask-bigquery and discovered that when using this environment file which specifies only the conda-forge channel, along with this conda-incubator/setup-miniconda GitHub actions setup, which is using mambaforge and strict channel priority, we still end up with a few packages installed from the main channel. This channel mixing is, I think, leading to CI errors for the project.

If I look at the logs from this CI build

2021-12-16T02:46:39.5858090Z [command]/Users/runner/miniconda3/condabin/conda config --show-sources
2021-12-16T02:46:39.7591180Z ==> /Users/runner/miniconda3/.condarc <==
2021-12-16T02:46:39.7592030Z channels:
2021-12-16T02:46:39.7593320Z   - conda-forge
2021-12-16T02:46:39.7593660Z 
2021-12-16T02:46:39.7594130Z ==> /Users/runner/.condarc <==
2021-12-16T02:46:39.7594690Z auto_update_conda: False
2021-12-16T02:46:39.7595240Z auto_activate_base: False
2021-12-16T02:46:39.7595800Z notify_outdated_conda: False
2021-12-16T02:46:39.7596340Z changeps1: False
2021-12-16T02:46:39.7596820Z pkgs_dirs:
2021-12-16T02:46:39.7597760Z   - /Users/runner/conda_pkgs_dir
2021-12-16T02:46:39.7598350Z channel_priority: strict
2021-12-16T02:46:39.7598860Z channels:
2021-12-16T02:46:39.7599710Z   - conda-forge
2021-12-16T02:46:39.7600550Z   - defaults
2021-12-16T02:46:39.7601040Z always_yes: True

it appears conda config --show-sources, which is run during setup-miniconda shows, two separate sources:

So the defaults channel is being added at some point, but it's not clear to me where and how I can disable it from being added. Any help is appreciated

jakirkham commented 2 years ago

A simple way to remove would be to just do conda config --remove channels defaults

Could also override the condarc with the channels you want

goanpeca commented 2 years ago

Hi @jrbourbeau

So we should be using /Users/runner/.condarc and not miniconda3/.condarc it seems

We will take a look

jakirkham commented 2 years ago

Ran into this as well in issue ( https://github.com/conda-forge/clangdev-feedstock/issues/166 ), which led to a bit of a confusing linking error

javierggt commented 1 year ago

I think I have the same issue, although I did not use an environment file.

I can verify that with this workflow:

name: Setup Miniconda

on:
  repository_dispatch:
    types:
      - setup-miniconda

jobs:
  setup:
    runs-on: "macos-latest"
    name: Setup
    defaults:
      run:
        shell: bash -l {0}
    steps:
    - uses: conda-incubator/setup-miniconda@v2
      with:
        miniconda-version: "py38_4.8.3"
        python-version: "3.8"
        channels: conda-forge
    # - run: conda config --remove channels defaults
    - run: conda config --show channels
    - run: cat /Users/runner/.condarc

the defaults channel is still used, and the contents of /Users/runner/.condarc are:

notify_outdated_conda: false
pkgs_dirs:
  - /Users/runner/conda_pkgs_dir
channels:
  - conda-forge
  - defaults
auto_activate_base: true
auto_update_conda: false
always_yes: true
changeps1: false

Also, using the workaround suggested by @jakirkham works.

jakirkham commented 1 year ago

Something else worth trying might be adding nodefaults to the channels

victorlin commented 1 year ago

This is interesting behavior of Conda, to always add defaults unless channels is already defined:

echo "" > test.condarc
conda config --add channels conda-forge --file test.condarc
cat test.condarc
# channels:
#   - conda-forge
#   - defaults

echo "channels: []" > test.condarc
conda config --add channels conda-forge --file test.condarc
cat test.condarc
# channels:
#   - conda-forge
liamhuber commented 2 weeks ago

Something else worth trying might be adding nodefaults to the channels

This is even done in the source code for example 6 (although that's not what's shown on the readme); unfortunately all this does is add - nodefaults to the channel list:

Screen Shot 2024-08-26 at 14 10 59

Log source for image: https://github.com/conda-incubator/setup-miniconda/actions/runs/10551479166/job/29228977318

Although this doesn't seem like what's intended from the example, it is intelligible from the source:

https://github.com/conda-incubator/setup-miniconda/blob/e5293c8fd23bf30f6ad37a6281c8a924c8938440/src/conda.ts#L128-L131