Skip to content
Latchkey

ocamlfind "Package X not found" in CI

ocamlfind (findlib) resolves libraries by their installed META files. When it cannot find one, the library is not installed in the current switch, or the switch environment findlib reads is not the one that has it.

What this error means

A build fails with "ocamlfind: Package X not found" or "No such package: X", even though opam install X seemed to run.

ocamlfind
ocamlfind: Package `ppx_deriving` not found - required by `myapp`
Error: Program ocamlfind failed

Common causes

The library is not installed in this switch

The package was installed into a different switch, or never installed, so findlib has no META for it here.

The switch environment was not applied

Without eval $(opam env), findlib reads the wrong OCAMLPATH and cannot see the installed package.

How to fix it

Install the library into the active switch

  1. Confirm the active switch with opam switch show.
  2. Install the missing library into it.
  3. Apply the switch env before building.
Terminal
opam install ppx_deriving --yes
eval $(opam env)

List what findlib can actually see

Verify the package is visible to findlib in this environment.

Terminal
ocamlfind list | grep ppx_deriving

How to prevent it

  • Install project deps with opam install . --deps-only in CI.
  • Apply eval $(opam env) before ocamlfind-driven builds.
  • Keep all builds in a single switch per job.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →