dune "Error: Unbound constructor" in CI
The compiler saw a constructor name with no matching variant in scope. Usually the type that defines it is in an unopened module, or the installed library version renamed or removed the constructor.
What this error means
dune build fails with "Error: Unbound constructor X", often after a dependency upgrade changed a variant type.
dune
File "lib/state.ml", line 12, characters 4-11:
12 | | Pending -> ...
^^^^^^^
Error: Unbound constructor PendingCommon causes
The type is defined in an unopened module
The constructor belongs to a variant in another module that was not opened, so its bare name is not in scope.
The variant changed across a library version
CI resolved a version where the constructor was renamed or removed, so code that compiled locally fails here.
How to fix it
Qualify the constructor or open its module
- Reference the constructor through its module, e.g.
Status.Pending. - Or add
open Statusat the top of the file. - Rebuild to confirm the constructor resolves.
lib/state.ml
open Status
let x = PendingAlign the library version
If the variant changed between releases, pin the version whose constructors match your code.
Terminal
opam pin add status_lib 2.1.0 --yesHow to prevent it
- Qualify or open the module that defines a variant type.
- Pin library versions so variant definitions stay stable in CI.
- Review changelog entries before bumping dependency versions.
Related guides
dune "Error: Unbound value" in CIFix OCaml "Error: Unbound value X" under dune in CI - the name is not in scope: a typo, a missing open, or a…
dune "Error: This expression has type ... but ... was expected" in CIFix OCaml "Error: This expression has type X but an expression was expected of type Y" under dune in CI - a r…
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:…