opam "The compiler ... is not installed" in CI
opam was asked to use an OCaml compiler version that does not exist in the current switch. The compiler was never installed, or the requested version string does not match an available base package.
What this error means
opam fails with "[ERROR] The compiler 5.2.0 is not installed" or "No compiler matching ... found", usually right after switch creation in CI.
opam
[ERROR] The compiler ocaml-base-compiler.5.2.0 is not installed. It is however
available in the repositories: run 'opam install ocaml-base-compiler.5.2.0'Common causes
The requested compiler version was never provisioned
setup-ocaml or opam switch create asked for a version the switch does not have, so opam cannot select it.
A version string that does not resolve to a base package
A typo or an unavailable point release means no ocaml-base-compiler matches, so the switch stays without a compiler.
How to fix it
Pin a real compiler version in setup-ocaml
Request a compiler the action supports so the switch is created with it present.
.github/workflows/ci.yml
- uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: '5.2'Install the compiler into the switch
- Run
opam updateso the compiler package is visible. - Install the exact base compiler the error names.
- Re-run the switch selection after it is present.
Terminal
opam update
opam install ocaml-base-compiler.5.2.0 --yesHow to prevent it
- Request a supported compiler version in setup-ocaml.
- Run
opam updatebefore switch creation in CI. - Avoid pinning obscure point releases that may be unavailable.
Related guides
opam "No switch is currently set" / switch not found in CIFix opam "[ERROR] No switch is currently set" / "There is no switch named X" in CI - no active switch, so opa…
opam "command not found" after setup-ocaml in CIFix "opam: command not found" in CI - a step ran opam before setup-ocaml provisioned it, or in a shell where…
opam "Sorry, no solution found" dependency conflict in CIFix opam "Sorry, no solution found" in CI - the solver could not choose package versions that satisfy every c…