diff --git a/.github/workflows/build_workflow.yml b/.github/workflows/build_workflow.yml index 74218ba811..7593331504 100644 --- a/.github/workflows/build_workflow.yml +++ b/.github/workflows/build_workflow.yml @@ -74,15 +74,17 @@ jobs: - if: ${{ steps.skip_check.outputs.should_skip != 'true' }} name: Set up Conda Environment - uses: conda-incubator/setup-miniconda@v3 + uses: mamba-org/setup-micromamba@v2 with: - activate-environment: "compass_ci" - miniforge-version: latest - channels: conda-forge,e3sm/label/compass - channel-priority: strict - use-mamba: false - auto-update-conda: true - python-version: ${{ matrix.python-version }} + environment-name: compass_test + init-shell: bash + condarc: | + channel_priority: strict + channels: + - conda-forge + - e3sm/label/compass + create-args: >- + python=${{ matrix.python-version }} - if: ${{ steps.skip_check.outputs.should_skip != 'true' }} name: Install compass diff --git a/.github/workflows/docs_workflow.yml b/.github/workflows/docs_workflow.yml index dda8d900a3..20e4388f35 100644 --- a/.github/workflows/docs_workflow.yml +++ b/.github/workflows/docs_workflow.yml @@ -27,15 +27,17 @@ jobs: - if: ${{ steps.skip_check.outputs.should_skip != 'true' }} name: Set up Conda Environment - uses: conda-incubator/setup-miniconda@v3 + uses: mamba-org/setup-micromamba@v2 with: - activate-environment: "compass_ci" - miniforge-version: latest - channels: conda-forge,e3sm/label/compass - channel-priority: strict - use-mamba: false - auto-update-conda: true - python-version: ${{ env.PYTHON_VERSION }} + environment-name: compass_test + init-shell: bash + condarc: | + channel_priority: strict + channels: + - conda-forge + - e3sm/label/compass + create-args: >- + python=${{ env.PYTHON_VERSION }} - if: ${{ steps.skip_check.outputs.should_skip != 'true' }} name: Install compass diff --git a/conda/shared.py b/conda/shared.py index 702794ec13..27de88ce82 100644 --- a/conda/shared.py +++ b/conda/shared.py @@ -95,19 +95,19 @@ def get_conda_base(conda_base, config, shared=False, warn=False): if shared: conda_base = config.get('paths', 'compass_envs') elif conda_base is None: - if 'CONDA_EXE' in os.environ: - # if this is a test, assume we're the same base as the - # environment currently active - conda_exe = os.environ['CONDA_EXE'] - conda_base = os.path.abspath( - os.path.join(conda_exe, '..', '..')) + try: + conda_base = subprocess.check_output( + ['conda', 'info', '--base'], text=True + ).strip() if warn: print(f'\nWarning: --conda path not supplied. Using conda ' f'installed at:\n' f' {conda_base}\n') - else: - raise ValueError('No conda base provided with --conda and ' - 'none could be inferred.') + except subprocess.CalledProcessError as e: + raise ValueError( + 'No conda base provided with --conda and ' + 'none could be inferred.' + ) from e # handle "~" in the path conda_base = os.path.abspath(os.path.expanduser(conda_base)) return conda_base