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 failedCommon 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
- Confirm the active switch with
opam switch show. - Install the missing library into it.
- 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_derivingHow to prevent it
- Install project deps with
opam install . --deps-onlyin CI. - Apply
eval $(opam env)before ocamlfind-driven builds. - Keep all builds in a single switch per job.
Related guides
dune "Library X not found" in the search path in CIFix dune "Error: Library X not found" / "not found in the dune search path" in CI - the library is not instal…
opam env not evaluated (dune/ocaml not on PATH) in CIFix "dune: command not found" / wrong ocaml in CI - the switch environment was never applied because `eval $(…
dune "Error: Unbound module X" in CIFix OCaml "Error: Unbound module X" under dune in CI - the referenced module is not in the compilation scope:…