# Stdune fails to compile

**URL:** <https://discuss.ocaml.org/t/stdune-fails-to-compile/14542>\
**Category:** Ecosystem\
**Tags:** install, ocaml-lsp-server, opam, dune\
**Created:** [April 23, 2024, 12:42pm UTC](https://discuss.ocaml.org/t/stdune-fails-to-compile/14542 "2024-04-23T12:42:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pigeonsownme](https://avatars.discourse-cdn.com/v4/letter/p/e95f7d/32.png) [@pigeonsownme](https://discuss.ocaml.org/u/pigeonsownme)\
**Post date:** [April 23, 2024, 12:42pm UTC](https://discuss.ocaml.org/t/stdune-fails-to-compile/14542/1 "2024-04-23T12:42:11Z")

</div>

Output of `opam install stdune` :

```auto
#=== ERROR while compiling stdune.3.15.0 ======================================#
# context 2.1.5 | linux/x86_64 | ocaml.5.1.1 | https://opam.ocaml.org#f2df0b10
# path ~/.opam/default/.opam-switch/build/stdune.3.15.0
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p stdune -j 7 @install
# exit-code 1
# env-file ~/.opam/log/stdune-953120-c77bb5.env
# output-file ~/.opam/log/stdune-953120-c77bb5.out
### output ###
# Error: The files /usr/lib/ocaml/dyn/dyn.cmi
# [...]
# make inconsistent assumptions over interface Pp
# (cd _build/default && /usr/bin/ocamlc.opt -w -40 -alert -unstable -g -bin-annot -I otherlibs/stdune/src/.stdune.objs/byte -I /home/willow/.opam/default/lib/csexp -I /home/willow/.opam/default/lib/pp -I /usr/lib/ocaml/dyn -I /usr/lib/ocaml/ordering -I /usr/lib/ocaml/unix -I otherlibs/stdune/dune_filesystem_stubs/.dune_filesystem_stubs.objs/byte -no-alias-deps -open Stdune__ -o otherlibs/stdune[...]
# File "otherlibs/stdune/src/exn_with_backtrace.mli", line 1:
# Error: The files otherlibs/stdune/src/.stdune.objs/byte/stdune__Result.cmi
# and /home/willow/.opam/default/lib/pp/pp.cmi
# make inconsistent assumptions over interface Pp
# (cd _build/default && /usr/bin/ocamlc.opt -w -40 -alert -unstable -g -bin-annot -I otherlibs/stdune/src/.stdune.objs/byte -I /home/willow/.opam/default/lib/csexp -I /home/willow/.opam/default/lib/pp -I /usr/lib/ocaml/dyn -I /usr/lib/ocaml/ordering -I /usr/lib/ocaml/unix -I otherlibs/stdune/dune_filesystem_stubs/.dune_filesystem_stubs.objs/byte -no-alias-deps -open Stdune__ -o otherlibs/stdune[...]
# File "otherlibs/stdune/src/path.mli", line 1:
# Error: The files otherlibs/stdune/src/.stdune.objs/byte/stdune__Path_intf.cmi
# and /home/willow/.opam/default/lib/pp/pp.cmi
# make inconsistent assumptions over interface Pp

```

I’m trying to install `ocaml-lsp-server`, which depends on `stdune`. For some reason, `stdune` always fails to install on my machine… I tried doing this in a fresh opam switch, and I still got the same exact error.

Please help ! 😢

---

<div class="post-metadata">

**Author:** ![pigeonsownme](https://avatars.discourse-cdn.com/v4/letter/p/e95f7d/32.png) [@pigeonsownme](https://discuss.ocaml.org/u/pigeonsownme)\
**Post date:** [April 23, 2024, 12:46pm UTC](https://discuss.ocaml.org/t/stdune-fails-to-compile/14542/2 "2024-04-23T12:46:01Z")

</div>

As of now, I’ve also tried running `opam clean` first, and restarting my computer.

---

<div class="post-metadata">

**Author:** ![nojb](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nojb/32/519_2.png) [@nojb](https://discuss.ocaml.org/u/nojb)\
**Post date:** [April 23, 2024, 1:25pm UTC](https://discuss.ocaml.org/t/stdune-fails-to-compile/14542/3 "2024-04-23T13:25:51Z")

</div>

> [@pigeonsownme](#):
>
> ```auto
> # Error: The files /usr/lib/ocaml/dyn/dyn.cmi
> 
> ```

This line seems fishy. If you are using OPAM you should not normally see any files installed outside of the OPAM prefix `~/.opam`, like you see here.

Most probably you have a mixture of OPAM-installed and system-installed libraries and/or tools. The most typical suspect is `ocamlfind`. Can you print the result of `ocamlfind printconf`?

Cheers,  
Nicolas

---

<div class="post-metadata">

**Author:** ![pigeonsownme](https://avatars.discourse-cdn.com/v4/letter/p/e95f7d/32.png) [@pigeonsownme](https://discuss.ocaml.org/u/pigeonsownme)\
**Post date:** [April 23, 2024, 1:44pm UTC](https://discuss.ocaml.org/t/stdune-fails-to-compile/14542/4 "2024-04-23T13:44:42Z")

</div>

```auto
$ ocamlfind printconf
Effective configuration:
Configuration file:
    /home/willow/.opam/default/lib/findlib.conf
Search path:
    /usr/lib/ocaml
    /home/willow/.opam/default/lib
Packages will be installed in/removed from:
    /home/willow/.opam/default/lib
META files will be installed in/removed from:
    the corresponding package directories
The standard library is assumed to reside in:
    /usr/lib/ocaml
The ld.conf file can be found here:
    /usr/lib/ocaml/ld.conf

```

I tried looking for such libraries, and I’m not sure if I have any. Only things I installed throught my package manager are `ocaml`, `ocaml-compiler-libs`, and `opam` (at least, as far as I’m aware).

---

<div class="post-metadata">

**Author:** ![nojb](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nojb/32/519_2.png) [@nojb](https://discuss.ocaml.org/u/nojb)\
**Post date:** [April 23, 2024, 1:48pm UTC](https://discuss.ocaml.org/t/stdune-fails-to-compile/14542/5 "2024-04-23T13:48:55Z")

</div>

> [@pigeonsownme](#):
>
> Only things I installed throught my package manager are `ocaml`, `ocaml-compiler-libs`, and `opam` (at least, as far as I’m aware).

By chance, did you install Dune with your system package manager? What is the result of `ocamlfind query dyn`?

Cheers,  
Nicolas

---

<div class="post-metadata">

**Author:** ![pigeonsownme](https://avatars.discourse-cdn.com/v4/letter/p/e95f7d/32.png) [@pigeonsownme](https://discuss.ocaml.org/u/pigeonsownme)\
**Post date:** [April 23, 2024, 2:02pm UTC](https://discuss.ocaml.org/t/stdune-fails-to-compile/14542/6 "2024-04-23T14:02:33Z")

</div>

```auto
$ ocamlfind query dyn
/home/willow/.opam/default/lib/dyn

```

According to my package manager, I didn’t install dune through it.

Thanks for your time, by the way.

---

<div class="post-metadata">

**Author:** ![nojb](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nojb/32/519_2.png) [@nojb](https://discuss.ocaml.org/u/nojb)\
**Post date:** [April 23, 2024, 2:14pm UTC](https://discuss.ocaml.org/t/stdune-fails-to-compile/14542/7 "2024-04-23T14:14:11Z")

</div>

> [@pigeonsownme](#):
>
> According to my package manager, I didn’t install dune through it.

OK. We haven’t figured out why you have a few libraries installed in `/usr/lib/ocaml`, but if you just want to get things working, you could go ahead and simply delete `/usr/lib/ocaml/dyn`, `/usr/lib/ocaml/ordering` (these are the ones I see in your log, there may be others) and try again.

Alternatively, you may want to use an OCaml compiler installed via OPAM (ie `opam switch create ...`) which will be installed in `~/.opam` and will completely insulate you from your existing system installation.

> [@pigeonsownme](#):
>
> Thanks for your time, by the way.

Sure, you are welcome.

Cheers,  
Nicolas
