ocaml / dune

A composable build system for OCaml.
https://dune.build/
MIT License
1.57k stars 396 forks source link

Dangling internal path when using virtual library #10678

Open Josef-Thorne-A opened 2 weeks ago

Josef-Thorne-A commented 2 weeks ago

Expected Behavior

I'm trying to pin sexplib0 against my own version of it which uses virtual libraries for melange compatibility -- it should just work as long as I specify the correct implementation (melange for executables using melange and native for native executables).

Actual Behavior

The library itself compiles fine, but I into this error if I try to compile ppxlib against it with opam pin-- I don't think this is an issue with ppxlib but rather with dune or my dune configuration. I suspect this is a simple mistake on my part but it's beyond my ability to determine:

#=== ERROR while compiling ppxlib.0.32.1 ======================================#
# context     2.1.2 | linux/x86_64 | ocaml-base-compiler.5.1.1 | https://opam.ocaml.org#2c609820
# path        ~/programming/sexplib0-js/_opam/.opam-switch/build/ppxlib.0.32.1
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p ppxlib -j 23 @install
# exit-code   1
# env-file    ~/.opam/log/ppxlib-599093-d68309.env
# output-file ~/.opam/log/ppxlib-599093-d68309.out
### output ###
# (cd _build/default && /home/josef/programming/sexplib0-js/_opam/bin/ocamlc.opt -w -40 -safe-string -g -bin-annot -I stdppx/.stdppx.objs/byte -I /home/josef/programming/sexplib0-js/_opam/lib/sexplib0 -I /home/josef/programming/sexplib0-js/_opam/lib/stdlib-shims -no-alias-deps -o stdppx/.stdppx.objs/byte/stdppx.cmo -c -impl stdppx/stdppx.ml)
# File "stdppx/stdppx.ml", line 6, characters 8-26:
# 6 | include Sexplib0.Sexp_conv
#             ^^^^^^^^^^^^^^^^^^
# Error: Internal path Sexp_conv is dangling.
#        The compiled interface for module Sexp_conv was not found.

Reproduction

  1. clone this version (can also view the dune setup there): https://github.com/Josef-Thorne-A/sexplib0-js
  2. (Optional) I recommend creating a local opam switch and installing melange on it -- may need to briefly unpin sexplib0 to properly bootstrap since opam might pin to the local repo automatically and fail
  3. I recommend running dune build to make sure the library builds fine
  4. Try to pin sexplib0 to the local repo once step 3 is complete
  5. You should get this failure when it attempts to recompile ppxlib against the new version
  6. (Note, I tried putting the public names in the "implements" field as an experiment -- this is reflected in the linked repository, -- but it had no effect on the issue either way.)

Here is a graphviz from dune-deps. It doesn't look quite right to me:

graph

Specifications

Josef-Thorne-A commented 2 weeks ago

@anmonteiro helped me figure out that this was due to ppxlib having implicit_transitive_deps set to false in their dune-project

My personal issue is resolved -- however it would be helpful to have a more helpful error message if it's possible to have fine-grained enough detection of this type of issue.

rgrinberg commented 2 weeks ago

Try dune 3.17 on OCaml 5.2. It might be better. There's not much we can do otherwise without compiler support.