Neovim error: ocamllsp: program seems to be compiled with a version of OCaml that is not supported by Merlin

I installed ocaml-lsp-server and had it configured by the Mason Neovim plugin, which worked fine until I decided to use OCaml 5.0.0, at which point I started recieving the message:

ocamllsp: /path/to/project/_build/default/.projname.objs/byte/projname.cmi seems to be compiled with a version of OCaml that is not supported by Merlin.

I’ve checked with opam and my version of merlin (4.9-500) depends on "ocaml" {>= "5.0" & < "5.1"}. Same for ocaml-lsp-server (version 1.15.1-5.0).

I’m building with dune (version 3.8.1).

Did anything in the ocaml-lsp-server configuration change for Neovim that might require manual intervention?

1 Like

So the problem was that I didn’t know Mason didn’t use ocaml-lsp from my opam installation, but a standalone installation that was apparently outdated, so I had to uninstall ocaml-lsp from Mason so nvim-lspconfig would get the one from opam.

But I’m not completely sure what’s the current version of Mason’s ocaml-lsp, as mine only showed a dash “-” in the “installed version” field.

According to Package list |, as of today, the ocaml-lsp version used by Mason is 1.10.2, which depends on "ocaml" {>= "4.13" & < "4.14"}

Hi! How your neovim use the ocamllsp from opam ? I install ocaml-lsp-server using opam even used dune build -w in my project but neovim doesn´t recognize it. Did you change anything on your init.lua?

Are you using lsp-config, or any configuration framework?
For ocaml, I’m not using mason, but installing via opam in every switch I’m using.
Lsp-config looks for the executable in the current path, so an active switch with lsp server installed is all I need.

I’m using this: GitHub - nvim-lua/kickstart.nvim: A launch point for your personal nvim configuration and it uses nvim-lspconfig
And I have installed ocaml-lsp-server in my ocaml 5.0.0 switch