opam monorepo fails on repo with pin-depends
bikallem opened this issue · 9 comments
I executed command opam monorepo lock
. However, I get the following error.
==> Using 1 locally scanned package as the target.
opam-monorepo: Can't find all required versions.
Selected: base-bigarray.base base-threads.base base-unix.base
ocaml-base-compiler.4.14.0~beta1 ocaml-config.2
ocaml-options-vanilla.1 ocaml-base-compiler&benchmark1
ocaml-base-compiler ocaml-base-compiler ocaml-base-compiler
- benchmark1 -> (problem)
Rejected candidates:
benchmark1.zdev: Requires ocaml <= 4.12+domains
- ocaml -> ocaml.4.14.0
ocaml-base-compiler 4.14.0~beta1 requires = 4.14.0
The opam file has a pin-depends constraint.
The repro. repo is at https://github.com/bikallem/benchmark1/tree/pin-depends
Why is opam monorepo
trying to install 4.14 libs? My switch is 4.13.1 and 4.12+domains.
Hi, I have already encountered this error.
This is because by default, opam-monorepo
requires ocaml-base-compiler
in the solution, so it cannot select an ocaml-variant
compiler, such as 4.12.0+domains
. So if you run opam-monorepo on your 4.12+domains switch it shouldn't work. However on 4.13.1 I believe it should ?
The solution to get opam-monorepo to work on 4.12+domains is to explicitely add a dependency on ocaml-variants
in your opam file.
Do you mean like below in opam file?
depends: [
- "ocaml" {<= "4.12+domains"}
+ "ocaml-variants" {<= "4.12+domains"}
....
Just tried the above, get even bigger constraint error.
==> Using 1 locally scanned package as the target.
opam-monorepo: Can't find all required versions.
Selected: base.v0.14.3 base-bigarray.base base-bytes.base base-domains.base
base-nnp.base base-threads.base base-unix.base
base_bigstring.v0.14.0 base_quickcheck.v0.14.1 bechamel.0.2.0
bechamel-notty.0.2.0 benchmark1.zdev bin_prot.v0.14.0 core.v0.14.1
core_bench.v0.14.0 core_kernel.v0.14.2 csexp.1.5.1 dune.3.0.2
dune-configurator.3.0.2 fieldslib.v0.14.0 findlib.1.8.1+dune
jane-street-headers.v0.14.0 jst-config.v0.14.1 num.1.3+dune
ocaml-compiler-libs.v0.12.4 ocaml-config.2 ocaml-option-nnp.1
ocamlfind.1.8.1+dune octavius.1.2.2 parsexp.v0.14.2
ppx_assert.v0.14.0 ppx_base.v0.14.0 ppx_bench.v0.14.1
ppx_bin_prot.v0.14.0 ppx_cold.v0.14.0 ppx_compare.v0.14.0
ppx_custom_printf.v0.14.1 ppx_derivers.1.2.1 ppx_enumerate.v0.14.0
ppx_expect.v0.14.2 ppx_fields_conv.v0.14.2
ppx_fixed_literal.v0.14.0 ppx_hash.v0.14.0 ppx_here.v0.14.0
ppx_inline_test.v0.14.1 ppx_jane.v0.14.0 ppx_js_style.v0.14.1
ppx_let.v0.14.0 ppx_module_timer.v0.14.0 ppx_optcomp.v0.14.3
ppx_optional.v0.14.0 ppx_pipebang.v0.14.0 ppx_sexp_conv.v0.14.3
ppx_sexp_message.v0.14.1 ppx_sexp_value.v0.14.0 ppx_stable.v0.14.1
ppx_string.v0.14.1 ppx_typerep_conv.v0.14.2
ppx_variants_conv.v0.14.2 ppxlib.0.24.0 re.1.10.3 seq.base+dune
sexplib.v0.14.0 sexplib0.v0.14.0 spawn.v0.15.0
splittable_random.v0.14.0 stdio.v0.14.0 stdlib-shims.0.3.0
textutils.v0.14.0 time_now.v0.14.0 timezone.v0.14.0 typerep.v0.14.0
variantslib.v0.14.0 ocaml-base-compiler ocaml-base-compiler
base-domains ocaml-variants ocaml
- fmt -> (problem)
bechamel 0.2.0 requires >= 0.9.0
Rejected candidates:
fmt.0.9.0: Doesn't build with dune
fmt.0.8.10: Doesn't build with dune
fmt.0.8.9: Doesn't build with dune
fmt.0.8.8: Doesn't build with dune
fmt.0.8.7: Doesn't build with dune
...
- notty -> (problem)
No usable implementations:
notty.0.2.2: Doesn't build with dune
notty.0.2.1: Doesn't build with dune
notty.0.2.0: Doesn't build with dune
notty.0.1.1: Doesn't build with dune
notty.0.1.0: Doesn't build with dune
- ocaml -> ocaml.4.12.0
ocaml-variants 4.12.0+domains requires = 4.12.0
- ocaml-base-compiler -> (problem)
Rejected candidates:
ocaml-base-compiler.4.14.0~beta1: In same conflict class (ocaml-core-compiler) as ocaml-variants
ocaml-base-compiler.4.14.0~alpha2: In same conflict class (ocaml-core-compiler) as ocaml-variants
ocaml-base-compiler.4.14.0~alpha1: In same conflict class (ocaml-core-compiler) as ocaml-variants
ocaml-base-compiler.4.13.1: In same conflict class (ocaml-core-compiler) as ocaml-variants
ocaml-base-compiler.4.13.0: In same conflict class (ocaml-core-compiler) as ocaml-variants
...
- ocaml-variants -> ocaml-variants.4.12.0+domains
benchmark1 zdev requires <= 4.12.0+domains
Do you mean like below in opam file?
Yes, exactly. It is just a temporary fix, I believe opam-monorepo should behave correctly from the start when a switch with ocaml-variants
is used.
Now you're having two main errors:
fmt
doesn't build with dune: it's because with opam-monorepo all dependencies have to usedune
as a build system, which is not the case of the upstreamfmt
. Instead you need to add https://github.com/dune-universe/opam-overlays as an extra opam-repository.notty
is more tricky, because the latest released version doesn't build with dune, and it is not present in opam-overlays. But I see it has been ported to dune since then, so pinningnotty
to the upstream repository (https://github.com/pqwy/notty) should work.
my opam repo prints below,
[NOTE] These are the repositories in use by the current switch. Use '--all' to see all configured
repositories.
<><> Repository configuration for switch 4.12.0+domains <><><><><><><><><><><><>
1 dune-universe git+https://github.com/dune-universe/opam-overlays.git
2 multicore git+https://github.com/ocaml-multicore/multicore-opam.git
3 default https://opam.ocaml.org
So I removed both nottty and fmt from my depends list and opam monorepo lock
now seems to succeed.
Oh I didn't see the fmt requires >= 0.9.0
, indeed we need to care that of that release in dune-universe
Indeed we're planning on using local switch invariants when running the solver. At the moment, it simply uses the constraints from your opam files and picks the highest available OCaml version matching them.
As @TheLortex mentioned, this has caused issues in the past where it selected compiler variants almost by default since the +
part made the version compare as higher.
By default now, opam-monorepo
enforces that the solver selects an ocaml-base-compiler
as that is what the vast majority of users want. If you want a specific variant selected, you need to state it explicitly in your dependency formula. That means depending on, for example, ocaml-variant+flambda
for 4.11 or lower. For 4.12 or higher, that means depending on ocaml-option-flambda
. Both alternatives should be recognized by opam-monorepo.
Closing this as the fix for the initial error issue was that you needed ocaml-variant
instead of ocaml
and the second error was caused by not adding the opam-overlays repository.