Repository navigation
Open
Labels
dev toolsDune's package-management of developer tools (e.g. `dune tools install ocamlformat`)package managementDune's package management — `(pkg)` stanza, lockdirs, `dune pkg` commands
Description
Expected Behavior
Adding constraints to developer tools in general, and ocamlformat in particular lets you install the version of ocamlformat per the constraints (as long as it exists)
Actual Behavior
Adding constraints to the path of ocamlformat leads it the path being treated as an external path outside _build, but in reality it is inside _build.
Internal error, please report upstream including the contents of _build/log.
Description:
("as_outside_build_dir_exn",
{ path =
In_build_dir ".dev-tools.locks/ocamlformat/ocaml-compiler-libs.files"
})
Raised at Stdune__Code_error.raise in file "stdune__Code_error.ml", line 11,
characters 30-62
Called from Dune_rules__Lock_rules.scan_lock_directory.scan in file
"dune_rules__Lock_rules.ml", line 431, characters 25-60
Called from Fiber__Core.apply2 in file "fiber__Core.ml", line 93, characters
6-11
-> required by ("gen-rules", In_build_dir "_private/default/.lock")
-> required by ("load-dir", In_build_dir "_private/default/.lock")
-> required by
("build-file", In_build_dir "_private/default/.lock/dune.lock")
-> required by ("<unnamed>", ())
-> required by
("gen-rules", In_build_dir "_private/default/.dev-tool/ocamlformat")
-> required by
("gen-rules", In_build_dir "_private/default/.dev-tool/ocamlformat/target")
-> required by
("gen-rules",
In_build_dir "_private/default/.dev-tool/ocamlformat/target/bin")
-> required by
("load-dir",
In_build_dir "_private/default/.dev-tool/ocamlformat/target/bin")
-> required by
("build-file",
In_build_dir
"_private/default/.dev-tool/ocamlformat/target/bin/ocamlformat")
-> required by ("toplevel", ())
I must not crash. Uncertainty is the mind-killer. Exceptions are the
little-death that brings total obliteration. I will fully express my cases.
Execution will pass over me and through me. And when it has gone past, I
will unwind the stack along its path. Where the cases are handled there will
be nothing. Only I will remain.
Reproduction
- PR with a reproducing test:
$ cat > dune <<'EOF'
(executable
(public_name main))
EOF
$ cat > dune-workspace <<'EOF'
(lang dune 3.21)
(pkg enabled)
(repository
(name oxcaml)
(url git+file:///home/sudha/ocaml/work/oxcaml/oxcaml-opam-repository))
(pin
(name ocamlbuild)
(url "git+https://github.com/Sudha247/ocamlbuild#oxcaml+dune")
(package
(name ocamlbuild)
(version 0.15.0+ox)))
(lock_dir
(path "dune.lock")
(repositories overlay oxcaml upstream))
(lock_dir
(path "_build/.dev-tools.locks/ocamlformat")
(pins ocamlbuild)
(constraints
(ocaml-lsp-server (= 1.19.0+ox))
(ocaml-variants (= 5.2.0+ox)))
(repositories :standard oxcaml))
EOF
$ cat > dune-project <<'EOF'
(lang dune 3.21)
(package
(name hello-oxcaml)
(depends
ocaml
(ocaml-variants
(= 5.2.0+ox))))
EOF
$ cat > main.ml <<'EOF'
let () =
(* The `local_` keyword requires OxCaml *)
let local_ i = 42 in
let j = i + 1 in
Printf.printf "%d\n" j
EOF
$ dune tools install ocamlformat
Specifications
- Version of
dune(output ofdune --version):"Nightly build 2025-12-04T02:46:51Z, git revision b25137a5321432edb6a36a19c1c5d5484bab5252" - Version of
ocaml(output ofocamlc --version):5.2.0+ox - Operating system (distribution and version): Ubuntu 20.02
Metadata
Metadata
Assignees
Labels
dev toolsDune's package-management of developer tools (e.g. `dune tools install ocamlformat`)package managementDune's package management — `(pkg)` stanza, lockdirs, `dune pkg` commands
Activity
shonfeder commentedon Dec 11, 2025
Is this a duplicate (or at least a special case of) #12777 ?
Sudha247 commentedon Dec 15, 2025
It is definitely related to #12777. However, this one is a bug report of an existing failure, and #12777 is a feature enhancement request for specifying constraints.
Sudha247 commentedon Dec 22, 2025
The same behaviour happens when adding constraints to other dev tools such as
ocamllsp. As the error message indicates, I suspect it has something to do with the path,_build/.dev-tools.locks/ocaml-lsp-server, being treated as an external path when it is actually inside the_builddirectory.Sudha247 commentedon Dec 22, 2025
After digging into this a bit and trying to reproduce this with a cram test, I think this could be a special case of #12851. The failure happens specifically for
.patchfiles within.dev-tools.locks/. I will try to dig further.pkg enabledfails to build an oxcaml project without a lock #12851Add a reproduction case for ocaml#12851 and ocaml#12866
Add a reproduction case for ocaml#12851 and ocaml#12866
Add a reproduction case for ocaml#12851 and ocaml#12866
Add a reproduction case for ocaml#12851 and ocaml#12866
pkg enabledfails to build an oxcaml project without a lock #12851Add a reproduction case for ocaml#12851 and ocaml#12866