Skip to content

Fix conda env creation hang and clang build failure on macOS; improve install docs#2953

Open
rwest wants to merge 4 commits into
mainfrom
macinstall
Open

Fix conda env creation hang and clang build failure on macOS; improve install docs#2953
rwest wants to merge 4 commits into
mainfrom
macinstall

Conversation

@rwest
Copy link
Copy Markdown
Member

@rwest rwest commented May 14, 2026

Motivation or Problem

Two separate issues were encountered when doing a fresh source install on macOS (reported while setting up a new conda environment after pysidt-rmg was added as a dependency. See #2952):

  1. conda env create -f environment.yml hangs or is very slow. The previous Python constraint >=3.9,<3.12 causes the conda solver to consider the full package graph for three Python versions simultaneously. On systems with older conda/libmamba (pre-24.x) this can hang indefinitely; even on modern toolchains it imposes unnecessary solver load.

  2. make fails with clang: error: invalid version number in 'MACOSX_DEPLOYMENT_TARGET=11.0'. The conda-forge osx-64 Python package targets macosx-11.0, but Apple clang versions older than ~clang 13 (shipped with Xcode Command Line Tools before ~2021) do not recognise any macOS deployment target ≥ 11.0. Users whose Command Line Tools installation was never updated since macOS Big Sur was released hit this immediately.

Neither issue was documented, and the install guide gave no guidance on prerequisite tool versions.

Description of Changes

environment.yml

  • Tighten the Python pin from >=3.9,<3.12 to =3.11. This collapses the solver search space to a single Python version, making fresh environment creation fast and reliable.

.github/workflows/CI.yml

  • build-and-test job: add a "Pin Python version for CI matrix" step immediately after checkout that rewrites conda-forge::python =3.11 to conda-forge::python =<matrix-version> before setup-miniconda runs. This is necessary because setup-miniconda adds an equality pin rather than replacing the existing one, so a pre-existing =3.11 would conflict with the injected =3.9 or =3.10. The sed -i.bak / rm idiom works on both GNU sed (Linux) and BSD sed (macOS).
  • regression-test job: upgrade the hardcoded Python version from 3.9 to 3.11. There is no technical reason for regression tests (which compare chemistry output, not Python behaviour) to use an older Python; 3.9 was a historical artifact. With the file already pinned to 3.11, setup-miniconda's injected =3.11 is redundant but harmless, so no sed step is needed here.

documentation/source/users/rmg/installation/anacondaDeveloper.rst

  • Promote a new "Before you begin" step to the top of the numbered list covering:
    • macOS: check clang version, and how to reinstall Xcode Command Line Tools if outdated
    • conda: how to check version and force-upgrade when conda update fails to advance it
  • Remove the now-redundant step about manually switching to the libmamba solver (any conda version that warrants an upgrade will get libmamba automatically; the step was aimed at conda <23.10 which is very old).
  • Expand the conda env create step with the alternative conda create --file syntax (preferred on conda ≥ 26.3) and simplify the "conda command not found" recovery advice.
  • Cross-reference the CLT warning from the macOS compiler prerequisites paragraph.

Testing

  • Verified locally on macOS 26.5 (Intel x86_64, osx-64) with Apple clang 21.0.0 and conda 26.3.2:
    • conda env create -f environment.yml resolves successfully with the =3.11 pin.
    • make build completes without errors after reinstalling Xcode Command Line Tools.
  • The CI matrix change (sed rewrite + regression job Python bump) is untested locally but the logic is straightforward: the sed command is a literal string substitution, and the regression tests have no Python-version-specific assertions.

Reviewer Tips

  • The key invariant to check in CI.yml is that the "Pin Python version for CI matrix" sed step runs before the setup-miniconda step in build-and-test. The two steps are adjacent in the YAML with no conditional logic between them.
  • The regression job no longer needs a sed step because its environment file already has =3.11 and the hardcoded python-version: 3.11 in setup-miniconda injects a redundant but non-conflicting second =3.11 constraint.
  • conda_build.yml is not changed — it builds from .conda/meta.yaml and never reads environment.yml.

rwest and others added 3 commits May 14, 2026 13:31
environment.yml previously used `python >=3.9,<3.12` so that the
conda-incubator/setup-miniconda action could safely inject a
per-matrix equality pin without creating a contradiction.  That broad
range forces the solver to consider every compatible package set for
all three Python micro-versions simultaneously, which makes fresh
environment creation slow and, on some local setups with older
libmamba, can cause the solver to hang indefinitely.

Changes:
- environment.yml: tighten the pin to `=3.11`.  Users running
  `conda env create -f environment.yml` now get a fast solve because
  the solver only needs to consider packages for a single Python
  version.
- CI.yml (build-and-test): add a "Pin Python version for CI matrix"
  step immediately after checkout that rewrites `=3.11` to the matrix
  python-version before setup-miniconda runs.  The -i.bak/rm idiom
  works on both GNU sed (Linux) and BSD sed (macOS).
- CI.yml (regression-test): upgrade the hardcoded python-version from
  3.9 to 3.11.  There is no technical requirement for regression tests
  to use an older Python; 3.9 was a historical artifact.  With the
  pin already set to 3.11 in the file, setup-miniconda's injected
  `=3.11` is redundant but harmless.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…in note

Two classes of problems encountered during a macOS source install were
not covered by the existing documentation:

1. An outdated Xcode Command Line Tools installation (Apple clang 11,
   from 2019) causes `make` to fail with
   "clang: error: invalid version number in 'MACOSX_DEPLOYMENT_TARGET'"
   because that vintage of clang does not recognise macOS deployment
   targets >= 11.0.  Added a warning at the top of the page explaining
   how to detect and fix this, with the recommended reinstall command.

2. Conda versions older than ~24.0 (particularly libmamba 2.1.x) can
   hang indefinitely when solving the RMG environment.  Added guidance
   to check and update conda before starting, including the
   `conda install -n base conda=26.3` workaround for cases where
   `conda update` fails to advance the version.

Also added a brief note alongside the `conda env create` step
explaining why environment.yml now pins Python 3.11 (faster solves),
and cross-referenced the macOS CLT warning from the compiler
prerequisites section.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Previous version written by Claude. These changes written by me.
@rwest rwest requested review from JacksonBurns and Copilot May 14, 2026 18:01
Comment thread .github/workflows/CI.yml
Comment thread documentation/source/users/rmg/installation/anacondaDeveloper.rst Outdated
You just know someone is going to copy and paste that incorrectly into
their terminal....
@rwest rwest requested a review from JacksonBurns May 14, 2026 20:16
Copy link
Copy Markdown
Contributor

@JacksonBurns JacksonBurns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lovely - please merge at your leisure

@rwest rwest enabled auto-merge May 14, 2026 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't make conda environment on Intel Mac (Tahoe 26.3.1a)

2 participants