opam "install ... failed" while building dependencies in CI
opam resolved a solution but one of the packages failed to build during install. The real cause, a compile error or a missing system dependency for C stubs, is in the captured build log above the summary.
What this error means
opam install ends with "[ERROR] The following actions failed" and a list of packages, each pointing to a build log under ~/.opam/log.
[ERROR] The following actions failed
- build conf-gmp 4
The following actions were aborted
- build zarith 1.13
# fatal error: gmp.h: No such file or directoryCommon causes
A missing system library for a C-stub package
Packages like zarith or ssl need system headers (gmp, openssl) that the runner image does not ship, so the native build fails.
A genuine build failure in a dependency
A package version incompatible with the compiler, or a broken release, fails to compile during the install action.
How to fix it
Install the system dependencies first
Let opam report external deps, then install them (setup-ocaml can do this) before building.
opam install . --deps-only --yes --depext
# or install the OS package the log names, e.g.:
sudo apt-get install -y libgmp-devRead the package build log
- Open the log path opam prints for the failed package.
- Find the first
error:orfatal error:line. - Install the missing header or pin a compatible package version.
How to prevent it
- Use
--depext(or setup-ocaml depext) to pull system deps for C stubs. - Bake common
-devlibraries into a custom runner image. - Pin dependency versions known to build on the CI compiler.