Skip to content
Latchkey

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.

opam
[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 directory

Common 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.

Terminal
opam install . --deps-only --yes --depext
# or install the OS package the log names, e.g.:
sudo apt-get install -y libgmp-dev

Read the package build log

  1. Open the log path opam prints for the failed package.
  2. Find the first error: or fatal error: line.
  3. 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 -dev libraries into a custom runner image.
  • Pin dependency versions known to build on the CI compiler.

Frequently asked questions

What causes ""opam install failed""?
Packages like zarith or ssl need system headers (gmp, openssl) that the runner image does not ship, so the native build fails.
How do I fix "opam install failed"?
Let opam report external deps, then install them (setup-ocaml can do this) before building.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card