Bad .cmt files using dune multipackage installation process


I have a repository with various packages, let’s says A and B. B depends on A. A and B have their own opam file in the repository.

When I use dune build @install && dune install everything is installed, no problem. Except that the cmt_loadpath of .cmt files of B refer to A/.A.objs/byte directory, i.e. the directory used at compilation time of B, rather than the final installation directory of A. This is not a bug of course, but rather inconvenient.

Is there some dune magic to perform compilation and installation of each package one after the other, using the installed package rather than the files in _build ? In my example, this would consist in the following steps:

  • compile A
  • install A
  • compile B using the files of the installation directrory of A, not the files in _build,
  • install B.

Workaround: opam pining each package of the repository to compile and install each package works fine.

I think the -p <pkg> option of dune is what you’re looking for.
Assuming your packages are names pkg_a and pkg_b, the following should do what you want:

dune build -p pkg_a @install
dune install -p pkg_a
dune build -p pkg_b @install
dune install -p pkg_b

Thanks. Indeed this should work since this is what opam will do. But I hoped there was some dune command to do all this automatically. A opam reinstall A will handle dependencies and install everything in one command.