Dune, OxCaml and locking dependencies

I’m trying to build my repo with 0xCaml 5.2. This used to work earlier today but then I re-created the switches and now it doesn’t.

How do I figure out where the problem is?

This is my dune-project file

(lang dune 3.18)

(name habu)

(using menhir 3.0)

(package
 (name habu)
 (allow_empty)
 (depends
  (ocaml
   (= 5.2.0))
  (ocaml-variants
   (= 5.2.0+ox))
  (ocaml-base-compiler
   (= 5.2.0))
  ppxlib
  stdint
  menhir
  stdint
  sexplib
  ppx_sexp_conv
  ppx_expect
  ppx_inline_test))

My dune-workspace. The commented out bits were pre-OxCaml announcement

(lang dune 3.17)

;; (lock_dir
;;  (repositories ox default overlay))
;; (repository
;;  (name default)
;;  (url "git+https://github.com/ocaml/opam-repository.git"))
;; (repository
;;  (name ox)
;;  (url "git+https://github.com/joelreymont/opam-repository.git#with-extensions"))

(env (dev (flags (:standard -warn-error -A))))

This is what I get when I run dune pkg lock.

❯ dune pkg lock
Error: Unable to solve dependencies for the following lock directories:
Lock directory dune.lock:
Couldn't solve the package dependency formula.
Selected candidates: base.v0.17.3 base-bigarray.base base-domains.base
                     base-nnp.base base-threads.base base-unix.base
                     csexp.1.5.2 dune-configurator.3.19.1 habu.dev
                     jane-street-headers.v0.17.0 jst-config.v0.17.0
                     menhir.20240715 menhirCST.20240715 menhirLib.20240715
                     menhirSdk.20240715 num.1.5-1 ocaml.5.2.0
                     ocaml-base-compiler.5.2.0 ocaml-compiler-libs.v0.17.0
                     ocaml-config.3 ocaml-options-vanilla.1
                     ocaml_intrinsics_kernel.v0.17.1 parsexp.v0.17.0
                     ppx_assert.v0.17.0 ppx_base.v0.17.0 ppx_cold.v0.17.0
                     ppx_compare.v0.17.0 ppx_derivers.1.2.1
                     ppx_enumerate.v0.17.0 ppx_expect.v0.17.3
                     ppx_globalize.v0.17.2 ppx_hash.v0.17.0 ppx_here.v0.17.0
                     ppx_inline_test.v0.17.1 ppx_optcomp.v0.17.1
                     ppx_sexp_conv.v0.17.1 ppxlib.0.36.0 sexplib.v0.17.0
                     sexplib0.v0.17.0 stdint.0.7.2 stdio.v0.17.0
                     stdlib-shims.0.3.0 time_now.v0.17.0 ocaml-base-compiler
                     ocaml-base-compiler system-mingw ocaml base-domains
                     ocaml-base-compiler
- dune -> dune.3.19.1
    User requested = 3.19
- ocaml-variants -> (problem)
    No usable implementations:
      ocaml-variants.5.5.0+trunk:
        Package does not satisfy constraints of local package habu
      ocaml-variants.5.4.0+trunk:
        Package does not satisfy constraints of local package habu
      ocaml-variants.5.4.0~alpha1+options:
        Package does not satisfy constraints of local package habu
      ocaml-variants.5.3.1+trunk:
        Package does not satisfy constraints of local package habu
      ocaml-variants.5.3.0+options:
        Package does not satisfy constraints of local package habu
      ...
- ppxlib_jane -> (problem)
    Rejected candidates:
      ppxlib_jane.v0.17.3: Requires ocaml >= 5.3.0
      ppxlib_jane.v0.17.2: Requires ocaml >= 5.3.0
      ppxlib_jane.v0.17.1: Requires ocaml >= 5.3.0
      ppxlib_jane.v0.17.0: Requires ppxlib >= 0.28.0 & < 0.36.0
- system-mingw -> (problem)
    No usable implementations:
      system-mingw.1: Availability condition not satisfied

My setup

❯ ocaml --version
The OCaml toplevel, version 5.2.0+ox

❯ opam switch
#  switch       compiler                                            description
   4.14.1       ocaml-base-compiler.4.14.1,ocaml-options-vanilla.1
          ocaml-base-compiler = 4.14.1 | ocaml-system = 4.14.1
   5.2.0        ocaml-base-compiler.5.2.0,ocaml-options-vanilla.1
          ocaml-base-compiler = 5.2.0 | ocaml-system = 5.2.0
→  5.2.0+ox     ocaml-options-vanilla.1,ocaml-variants.5.2.0+ox     ocaml-variants = 5.2.0+ox
   5.3.0        ocaml-base-compiler.5.3.0,ocaml-options-vanilla.1
          ocaml-base-compiler = 5.3.0 | ocaml-system = 5.3.0
   ocaml-local                                                      ocaml-local
   ocaml5       ocaml-base-compiler.5.3.0,ocaml-options-vanilla.1
          ocaml-base-compiler = 5.3.0 | ocaml-system = 5.3.0

❯ 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 5.2.0+ox <><><><><><><><><><><><><>  🐫
 1 ox      git+https://github.com/oxcaml/opam-repository.git
 2 default https://opam.ocaml.org

Running dune in verbose mode I see that it’s not using the OxCaml opam repo

❯ dune pkg lock --verbose
Shared cache: enabled-except-user-rules
Shared cache location: /Users/joelr/.cache/dune/db
Workspace root: /Users/joelr/Work/OCaml/habu
Auto-detected concurrency: 12
Running[4]: (cd /Users/joelr/.cache/dune/git-repo && /usr/bin/git ls-remote https://github.com/ocaml-dune/opam-overlays.git) > /var/folders/b5/r1rvht6j2mxflh71xgl6vr8m0000gn/T/dune_289313_output
Running[5]: (cd /Users/joelr/.cache/dune/git-repo && /usr/bin/git ls-remote https://github.com/ocaml/opam-repository.git) > /var/folders/b5/r1rvht6j2mxflh71xgl6vr8m0000gn/T/dune_9fdbd9_output

unlike opam which does

❯ 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 5.2.0+ox <><><><><><><><><><><><><>  🐫
 1 ox      git+https://github.com/oxcaml/opam-repository.git
 2 default https://opam.ocaml.org

Adding the repos to dune-workspace does the trick, though

(lang dune 3.17)

(lock_dir
 (repositories ox upstream overlay))

(repository
 (name ox)
 (url "git+https://github.com/oxcaml/opam-repository.git"))

Dune docs mention that the default repo should be available as :default and include both upstream and overlay. I get an undefined keyword error when I use that, though. I filed a Github issue, maybe the docs need to be updated.

2 Likes

It’s :standard instead of :default, e.g.

(lock_dir
 (repositories ox :standard))
2 Likes