Trouble upgrading ocaml-lsp-server on Mac

Visual Studio Code advises me to upgrade ocaml-lsp-server :

newer_ocaml_lsp

But my console disagrees :

console1

How can I fix this ?

I’m using dune 3.7.0, utop 2.11.0, Ocaml 4.14.0, opam 2.1.3 and VSCode 1.81.1 on my Mac.

Check that the current switch in left bottom corner is the right one. AFAIR VsCode looks for the PATHs in the context of selected switch

It is, I reset it by hand after every restart, and when I forget to do so VSCode warns me anyway

In GNU/Linux you can check the path of the running ocaml LSP server via

✗ readlink -f /proc/$(pidof ocamllsp)/exe                      
/media/work/.opam/4.14.1+flambda/bin/ocamllsp

If the path to the ocamllsp uses that wrong switch, then you selected the wrong one.
If ocamllsp runs from the correct switch, but VsCode warns anyway, it is false positive alarm which desires to be bugreported.

I usually start vscode via opam exec -- code path_to_dir but I don’t know how to do the same on Mac. In theory VsCode extension will select correct switch for you. In practice, I don’t want to check it.

So there should be a similar command that does the same on Mac. I tried to guess and failed so far

It’s certainly because your local Opam is not aware of the latest version of ocaml-lsp-server.

Try opam update. This fetches the last version of opam-repository, which is basically the list of all the packages.

1 Like