Stdune fails to compile

Output of opam install stdune :

#=== 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 ! :cry:

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

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

$ 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).

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

Cheers,
Nicolas

$ 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.

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.

Sure, you are welcome.

Cheers,
Nicolas

1 Like