Ocaml-lsp-server not compiling

I have a strange problem where ocaml-lsp-server won’t compile, with the following :

#=== ERROR while compiling ocaml-lsp-server.1.17.0 ============================#
# context     2.1.5 | linux/x86_64 | ocaml.5.1.1 | https://opam.ocaml.org#f2df0b10
# path        ~/uni/upc/S6/GA/Projet/_opam/.opam-switch/build/ocaml-lsp-server.1.17.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -j 7 ocaml-lsp-server.install --release
# exit-code   1
# env-file    ~/.opam/log/ocaml-lsp-server-38679-63a4c7.env
# output-file ~/.opam/log/ocaml-lsp-server-38679-63a4c7.out
### output ###
# [...]
# automatically added to the search path, but you should add -I +unix to the
# command-line to silence this alert (e.g. by adding unix to the list of
# libraries in your dune file, or adding use_unix to your _tags file for
# ocamlbuild, or using -package unix for ocamlfind).
# (cd _build/default && /usr/bin/ocamlopt.opt -w -40 -alert -unstable -g -I ocaml-lsp-server/src/.ocaml_lsp_server.objs/byte -I ocaml-lsp-server/src/.ocaml_lsp_server.objs/native -I /home/willow/uni/upc/S6/GA/Projet/_opam/lib/chrome-trace -I /home/willow/uni/upc/S6/GA/Projet/_opam/lib/csexp -I /home/willow/uni/upc/S6/GA/Projet/_opam/lib/dune-build-info -I /home/willow/uni/upc/S6/GA/Projet/_opam[...]
# File "_none_", line 1:
# Alert ocaml_deprecated_auto_include: 
# OCaml's lib directory layout changed in 5.0. The unix subdirectory has been
# automatically added to the search path, but you should add -I +unix to the
# command-line to silence this alert (e.g. by adding unix to the list of
# libraries in your dune file, or adding use_unix to your _tags file for
# ocamlbuild, or using -package unix for ocamlfind).

After reading the log, this seems to be the relevant part :

(cd _build/default && /usr/bin/ocamlopt.opt -w -40 -alert -unstable -g -I ocaml-lsp-server/src/.ocaml_lsp_server.objs/byte -I ocaml-lsp-server/src/.ocaml_lsp_server.objs/native -I /home/willow/.opam/default/lib/chrome-trace -I /home/willow/.opam/default/lib/csexp -I /home/willow/.opam/default/lib/dune-build-info -I /home/willow/.opam/default/lib/dune-rpc -I /home/willow/.opam/default/lib/dune-rpc/private -I /home/willow/.opam/default/lib/dyn -I /home/willow/.opam/default/lib/fiber -I /home/willow/.opam/default/lib/merlin-lib/analysis -I /home/willow/.opam/default/lib/merlin-lib/dot_protocol -I /home/willow/.opam/default/lib/merlin-lib/extend -I /home/willow/.opam/default/lib/merlin-lib/kernel -I /home/willow/.opam/default/lib/merlin-lib/ocaml_merlin_specific -I /home/willow/.opam/default/lib/merlin-lib/ocaml_parsing -I /home/willow/.opam/default/lib/merlin-lib/ocaml_typing -I /home/willow/.opam/default/lib/merlin-lib/ocaml_utils -I /home/willow/.opam/default/lib/merlin-lib/query_commands -I /home/willow/.opam/default/lib/merlin-lib/query_protocol -I /home/willow/.opam/default/lib/merlin-lib/utils -I /home/willow/.opam/default/lib/ocamlc-loc -I /home/willow/.opam/default/lib/ocamlformat-rpc-lib -I /home/willow/.opam/default/lib/ordering -I /home/willow/.opam/default/lib/pp -I /home/willow/.opam/default/lib/ppx_yojson_conv_lib -I /home/willow/.opam/default/lib/re -I /home/willow/.opam/default/lib/spawn -I /home/willow/.opam/default/lib/stdune -I /home/willow/.opam/default/lib/stdune/filesystem_stubs -I /home/willow/.opam/default/lib/xdg -I /home/willow/.opam/default/lib/yojson -I jsonrpc/src/.jsonrpc.objs/byte -I jsonrpc/src/.jsonrpc.objs/native -I lsp-fiber/src/.lsp_fiber.objs/byte -I lsp-fiber/src/.lsp_fiber.objs/native -I lsp/src/.lsp.objs/byte -I lsp/src/.lsp.objs/native -I ocaml-lsp-server/vendor/cmarkit/.cmarkit.objs/byte -I ocaml-lsp-server/vendor/cmarkit/.cmarkit.objs/native -I vendor/lev-fiber-csexp/.lev_fiber_csexp.objs/byte -I vendor/lev-fiber-csexp/.lev_fiber_csexp.objs/native -I vendor/lev-fiber/.lev_fiber.objs/byte -I vendor/lev-fiber/.lev_fiber.objs/native -I vendor/lev/.lev.objs/byte -I vendor/lev/.lev.objs/native -I vendor/odoc-parser/src/.odoc_parser.objs/byte -I vendor/odoc-parser/src/.odoc_parser.objs/native -intf-suffix .ml -no-alias-deps -open Ocaml_lsp_server__ -o ocaml-lsp-server/src/.ocaml_lsp_server.objs/native/ocaml_lsp_server__Diagnostics.cmx -c -impl ocaml-lsp-server/src/diagnostics.ml)
File "ocaml-lsp-server/src/diagnostics.ml", line 1:
Error: The files ocaml-lsp-server/src/.ocaml_lsp_server.objs/byte/ocaml_lsp_server__Import.cmi
       and /home/willow/.opam/default/lib/ocamlc-loc/ocamlc_loc.cmi
       make inconsistent assumptions over interface Pp

For some extra context, read this post. I’m not sure it’s what’s causing my problem in this case, however.

All help is appreciated :smiley:

Was this problem solved by the post in the other thread you’ve linked to? If not, sorry for the late reply!

Two things that are catching my attention:

  1. According to the error msg you’ve posted, your opam seems to be expecting OCaml 5.1.1 (see context) and, at the same time, seems to be using your system OCaml /usr/bin/ocamlopt rather than an ocaml-base-compiler from your switch. There are still quite a few distributions with an older OCaml than 5.1.1…What’s your system OCaml version (/usr/bin/ocamlopt --version)?
  2. I’m surprised that there seems to be a conflict with Pp: As far as I know, Pp has been stable for quite some time. This comment won’t help you fix your problem, but if your problem isn’t fixed yet and also point 1. doesn’t lead in the right direction, we might want to dig in that direction (potentially, asking dune maintainers if they have an idea what might be going on).