Package resolution in Opam with multiple repos

An opam installation can have multiple repositories which are ranked by their priority. What does that mean when searching for a package? What is the set of packages considered in the presence of multiple repositories as multiple strategies could be imagined, e.g.:

  • Repositories are searched in order
  • All repositories are considered and priorities are used to break ties

How do constraints of packages and priorities of repositories interact?

1 Like

Each opam switch has only one effective repository - the multiple repositories in a given switch’s list are unioned, with the priority list used to settle a tie between package.version.

This is used, for example, has a slight hack in opam 2.0, to have ocaml-beta.disabled in ocaml/opam-repository and ocaml-beta.enabled in ocaml/ocaml-beta-repository and when you add both repositories to a switch you get both ocaml-beta.enabled and ocaml-beta.disabled effectively available to “install” (the real “hack” is that enabled > disabled in a version comparison). It’s not the case that you only get the ocaml-beta package descriptions of the highest priority repository (which I think is what you intend with the first interpretation?)


(It is briefly covered in the manual, but I add that only to head off questions as to where it’s documented!!)

1 Like