# Bad .cmt files using dune multipackage installation process

**URL:** <https://discuss.ocaml.org/t/bad-cmt-files-using-dune-multipackage-installation-process/8485>\
**Category:** Ecosystem\
**Tags:** dune\
**Created:** [September 13, 2021, 10:07am UTC](https://discuss.ocaml.org/t/bad-cmt-files-using-dune-multipackage-installation-process/8485 "2021-09-13T10:07:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zoggy](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/zoggy/32/2919_2.png) [@Zoggy](https://discuss.ocaml.org/u/Zoggy)\
**Post date:** [September 13, 2021, 10:07am UTC](https://discuss.ocaml.org/t/bad-cmt-files-using-dune-multipackage-installation-process/8485/1 "2021-09-13T10:07:39Z")

</div>

Hi,

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.

---

<div class="post-metadata">

**Author:** ![Zoggy](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/zoggy/32/2919_2.png) [@Zoggy](https://discuss.ocaml.org/u/Zoggy)\
**Post date:** [September 14, 2021, 7:11am UTC](https://discuss.ocaml.org/t/bad-cmt-files-using-dune-multipackage-installation-process/8485/2 "2021-09-14T07:11:16Z")

</div>

Workaround: `opam pin`ing each package of the repository to compile and install each package works fine.

---

<div class="post-metadata">

**Author:** ![zozozo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/zozozo/32/59_2.png) [@zozozo](https://discuss.ocaml.org/u/zozozo)\
**Post date:** [September 14, 2021, 10:59am UTC](https://discuss.ocaml.org/t/bad-cmt-files-using-dune-multipackage-installation-process/8485/3 "2021-09-14T10:59:10Z")

</div>

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:

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

```

---

<div class="post-metadata">

**Author:** ![Zoggy](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/zoggy/32/2919_2.png) [@Zoggy](https://discuss.ocaml.org/u/Zoggy)\
**Post date:** [September 14, 2021, 11:15am UTC](https://discuss.ocaml.org/t/bad-cmt-files-using-dune-multipackage-installation-process/8485/4 "2021-09-14T11:15:12Z")

</div>

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.
