Skip to content

Commit bf378fe

Browse files
committed
CI: recreate conda env from conda-forge to avoid mixed-channel solve
pytorch/test-infra's setup-miniconda action pre-populates the conda env at ${CONDA_PREFIX} with cmake=3.22, ninja=1.10, pkg-config=0.29, and wheel=0.37 from the anaconda defaults channel. Our subsequent install of cmake=3.31.2 from conda-forge has to reconcile two channels in one solve, and that's been intermittently failing because conda-forge's newer cmake needs transitive deps (libzlib>=1.3.1, rhash>=1.4.5) that defaults' shipped versions don't satisfy. Patches that just tweak the solver flags (--strict-channel-priority, --override-channels alone, --update-deps) each address one symptom but expose another, because libmamba on macOS has gaps around channel priority and in-place upgrades that surface differently per runner class. Tear down the pre-populated env and recreate it from conda-forge only with --override-channels. The python version is read from the existing env so we recreate at parity. Because we recreate at the same prefix, ${CONDA_RUN}, ${CONDA_INSTALL}, and the ~80 workflow callsites that depend on those vars keep working unchanged. The cache layer in setup-miniconda caches the base/clone-source rather than the per-run env, so destroy+recreate doesn't disturb caching either. This is the surgical short-term fix. The lasting fix is to plumb a default-packages input through pytorch/test-infra's macos_job.yml so we can pass default-packages: "" and skip the wasted install entirely; that's a follow-up upstream PR. Authored with Claude Code.
1 parent e84a418 commit bf378fe

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

.ci/scripts/setup-conda.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,22 @@ set -ex
99

1010
install_conda() {
1111
pushd .ci/docker || return
12-
${CONDA_INSTALL} -c conda-forge -y --file conda-env-ci.txt
12+
13+
# The env created by pytorch/test-infra's setup-miniconda is pre-populated
14+
# with cmake=3.22 ninja=1.10 pkg-config=0.29 wheel=0.37 from the anaconda
15+
# defaults channel. Mixing those with conda-forge's newer transitive deps
16+
# required by our cmake=3.31.2 pin (libzlib>=1.3.1, rhash>=1.4.5) has been
17+
# intermittently failing the libmamba solver, especially on ephemeral
18+
# GitHub-hosted macOS runners where the env is fresh every job. Tear down
19+
# the pre-populated env and recreate it from conda-forge only so the solve
20+
# never has to reconcile two channels.
21+
PY_VERSION=$(conda run -p "${CONDA_PREFIX}" python -c \
22+
'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
23+
24+
conda env remove --prefix "${CONDA_PREFIX}" -y
25+
conda create --prefix "${CONDA_PREFIX}" -c conda-forge --override-channels -y \
26+
"python=${PY_VERSION}" --file conda-env-ci.txt
27+
1328
popd || return
1429
}
1530

0 commit comments

Comments
 (0)