Skip to content
Latchkey

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

  1. Run opam update so the compiler package is visible.
  2. Install the exact base compiler the error names.
  3. Re-run the switch selection after it is present.
Terminal
opam update
opam install ocaml-base-compiler.5.2.0 --yes

How to prevent it

  • Request a supported compiler version in setup-ocaml.
  • Run opam update before switch creation in CI.
  • Avoid pinning obscure point releases that may be unavailable.

Related guides

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