tarides / opam-monorepo

Assemble dune workspaces to build your project and its dependencies as a whole
ISC License
131 stars 27 forks source link

opam monorepo lock fails if repos specified #333

Open RyanGibb opened 2 years ago

RyanGibb commented 2 years ago

opam monorepo fails if the repos are specified:

$ ~/projects/opam-monorepo/_build/default/bin/opam_monorepo.exe lock --require-cross-compile --build-only hello-unix -l mirage/hello-unix.opam.locked --ocaml-version $(ocamlc --version) --opam-repositories '[/home/ryan/projects/opam-repository,/home/ryan/projects/opam-overlays,/home/ryan/projects/mirage-opam-overlays]'
==> Using 1 locally scanned package as the target.
opam_monorepo.exe: [ERROR] Solving opam-provided dependencies could not find a solution
opam_monorepo.exe: [ERROR] There is no eligible version of mirage that matches >= 4.1.0 & < 4.2.0
opam_monorepo.exe: [ERROR] Can't find all required versions.
...
- mirage -> (problem)
    hello-unix zdev requires >= 4.1.0 & < 4.2.0
    Rejected candidates:
      mirage.3.10.8: Incompatible with restriction: >= 4.1.0 & < 4.2.0
      mirage.3.10.7: Incompatible with restriction: >= 4.1.0 & < 4.2.0
      mirage.3.10.6: Incompatible with restriction: >= 4.1.0 & < 4.2.0
      mirage.3.10.5: Incompatible with restriction: >= 4.1.0 & < 4.2.0
      mirage.3.10.4: Incompatible with restriction: >= 4.1.0 & < 4.2.0
      ...
...

But works if the switch's repos are used:

$ opam repo list
[NOTE] These are the repositories in use by the current switch. Use '--all' to see all configured repositories.

<><> Repository configuration for switch default ><><><><><><><><><><><><><><><>
 1 mirage-overlays git+https://github.com/dune-universe/mirage-opam-overlays.git
 2 opam-overlays   git+https://github.com/dune-universe/opam-overlays.git
 3 default         https://opam.ocaml.org/
$ ~/projects/opam-monorepo/_build/default/bin/opam_monorepo.exe lock --require-cross-compile --build-only hello-unix -l mirage/hello-unix.opam.locked --ocaml-version $(ocamlc --version)
==> Using 1 locally scanned package as the target.
==> Found 64 opam dependencies for the target package.
==> Querying opam database for their metadata and Dune compatibility.
==> Calculating exact pins for each of them.
==> Wrote lockfile with 33 entries to mirage/hello-unix.opam.locked. You can now run opam monorepo pull to fetch their sources.
RyanGibb commented 2 years ago

This seems to be mirage specific as testing with a minimal project depending on package with an overlay in opam-overlays works

RyanGibb commented 2 years ago

Notably mirage changed dune to a test dependency in 4.0.0. But that begs the question why it works with the switch repos but not manually specified ones.

RyanGibb commented 2 years ago

Also the same error results with --add-opam-repositories or in the opam file x-opam-monorepo-opam-repositories.

Leonidas-from-XIV commented 2 years ago

Whether dune is a test dependency shouldn't matter I think, because it is special-cased in the code. If there is no dune, we can't build anything anyway :)