Skip to content

Re-sign binaries that conda leaves with invalid signatures on Intel Macs - #3038

Open
rwest wants to merge 1 commit into
mainfrom
macos-intel-codesign
Open

rwest wants to merge 1 commit into
mainfrom
macos-intel-codesign

Conversation

@rwest

@rwest rwest commented Nov 7, 2026

Copy link
Copy Markdown
Member

Note: This PR was drafted by Claude (Anthropic's AI assistant, via Claude Code) at Richard West's request.

Fixes #3037.

Why

On Intel Macs, conda leaves some binaries with invalid code signatures: it rewrites paths stored inside them during installation, but only re-signs them for osx-arm64 packages. The official Julia binaries run with Apple's hardened runtime, so Julia is killed ("Code Signature Invalid", exit code 137) as soon as it loads one. For example, using ReactionMechanismSimulator in julia is killed when PythonCall imports matplotlib's kiwisolver extension. RMG runs are unaffected, because there Python hosts Julia. See #3037 for the full diagnosis.

What this changes

  • utilities.py fix-macos-signatures (new). It reads conda's install records (conda-meta/*.json) to find the files conda patched in binary mode, checks each with codesign --verify, and re-signs (ad hoc) only those whose signature is invalid. Unsigned files and valid signatures are left alone. It does nothing on Linux or Windows. It's safe to re-run, and on Apple Silicon it should normally find nothing to do.
  • install_rms.sh runs it on macOS, after the script's last conda install and before it first starts Julia.
  • Installation docs (anacondaDeveloper.rst): a note describing the symptom and how to re-run the fix after later conda installs, which can break signatures again.

Testing

On an Intel Mac (macOS 26.7, conda 26.3.2 with the libmamba solver, Julia 1.10.9 from juliaup):

  • Before: codesign --verify reported 25 conda-patched files in rmg_env with invalid signatures. Importing, from julia through PythonCall, greenlet, kiwisolver or other affected modules killed Julia (exit 137), while importing them from python worked. using ReactionMechanismSimulator in julia was killed.
  • After re-signing, Julia imports all of them, and using ReactionMechanismSimulator works.
  • To test the command itself, I force-reinstalled kiwisolver (which brings back the invalid signature), then ran python utilities.py fix-macos-signatures. It re-signed kiwisolver plus 9 executables from glib and dbus that were also invalid, in about 11 s. A second run re-signed nothing.
  • bash -n and zsh -n pass on install_rms.sh. I have not run the full install_rms.sh with this change. macOS CI (Intel and Apple Silicon) will run it.

Not changed

install_rms.sh's "Loading RMS" check is followed by || echo "... continuing anyway", so a failed (or killed) load is reported as success. That's why this went unnoticed. I left that behaviour alone here.

🤖 Generated with Claude Code

When conda installs a package, it rewrites the build-time prefix stored
inside some binaries. For osx-arm64 packages it then re-signs them
(ad hoc), but for osx-64 packages it does not. Recent conda-forge osx-64
builds are ad hoc signed (e.g. kiwisolver >= 1.4.9; older builds were
unsigned), so after installation these files carry a signature that no
longer matches their contents.

Most processes, including conda's Python, don't care. But the official
Julia binaries (as installed by juliaup) run with Apple's hardened
runtime, and the kernel kills such a process (SIGKILL, "Code Signature
Invalid") as soon as it touches a modified page. So on an Intel Mac,
`using ReactionMechanismSimulator` in `julia` gets killed when
PythonCall imports matplotlib, and with it kiwisolver's extension module.
This includes the "Loading RMS" check that install_rms.sh itself runs,
whose failure is currently hidden by the script's "continuing anyway"
fallback. Running RMG itself is not affected, because there Python is
the host process and loads Julia into it.

This adds `python utilities.py fix-macos-signatures`, which reads
conda's own records (conda-meta/*.json) to find the files it patched in
binary mode, and re-signs only those whose signature is now invalid.
Unsigned files and files with valid signatures are left alone, so it is
safe to run repeatedly, and on Apple Silicon it normally finds nothing
to do. install_rms.sh runs it on macOS before it first starts Julia.
Because later `conda install`s can break signatures again, the
installation docs explain the symptom and how to re-run the fix.

micromamba (used by CondaPkg) has the same osx-arm64-only rule; pixi
(rattler) re-signs on all macOS platforms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

Intel Mac: Julia killed with "Code Signature Invalid" when loading RMS (conda leaves invalid signatures on osx-64 binaries)

1 participant