macOS runner: "dyld: Library not loaded ... image not found" in CI
At launch the dynamic linker tried to load a dylib from a hard-coded path and could not find it. The dependency is missing on the runner, or it was installed at a different prefix than the one baked into the binary.
What this error means
Running a tool or test fails with "dyld: Library not loaded: /usr/local/opt/.../lib.dylib, Reason: image not found" and the process aborts before doing any work.
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.74.dylib
Referenced from: /usr/local/bin/some-tool
Reason: image not foundCommon causes
A dependency was upgraded or removed
The binary references a specific dylib version; a brew upgrade bumped the version or relocated it, so the exact path no longer exists.
A different Homebrew prefix than expected
Apple silicon uses /opt/homebrew while Intel uses /usr/local. A binary built for one prefix cannot find dylibs on the other.
How to fix it
Reinstall or relink the dependency
- Identify the missing dylib from the dyld message.
- Reinstall the formula that provides it so the path is restored.
- Re-run the tool.
brew reinstall icu4c
brew link --overwrite icu4cPoint dyld at the right library path
When the library lives at a known location, set the fallback library path so dyld can find it.
export DYLD_FALLBACK_LIBRARY_PATH="$(brew --prefix)/lib"
some-tool --versionHow to prevent it
- Pin dependency versions so dylib paths stay stable.
- Account for
/opt/homebrewvs/usr/localacross architectures. - Reinstall a formula after a dependency upgrade breaks its links.