Trouble Setting up OCaml Platform and ocaml-lsp on WSL2/Debian

I had trouble installing ocaml-lsp-server as instructed on the VSCode OCaml Platform readme. When running:

opam pin add ocaml-lsp-server


 opam install ocaml-lsp-server

I keep seeing:

Sorry, no solution found: there seems to be a problem with your request.

So I tried the alternate instructions of building from source. However, I see several errors like:

Error: Library "ppx_yojson_conv_lib" not found.
Error: Library "dune-build-info" not found.

Then I ran:

dune external-lib-deps --missing @@default

This seems to have installed the missing libraries, but I’m not sure is the install in correct. Is it? How could I know? VS Code seems to have syntax highlighting and code completion.

And I’d much prefer to be able to use opam to update and upgrade ocaml-lsp-server. Is that still possible for me?

I’ve copied my terminal buffer to pastebin.

I’m using Debian installed from the Microsoft store on WSL2.

Any help would be appreciated.

Can you check

  1. which version of opam do you use ?
  2. do you have apt install aspcud performed?

opam 2.0.3
OCaml 4.05.0

I’m not familiar with aspcud, so no. A brief reading about it didn’t bring much clarity. What can it do?

It’s an external dependency solver which can be used by opam.

@Kakadu starting from opam 2.0 an external solver is no longer need In any case if opam is installed with one of the suppored package managers you shouldn’t worry about dependencies.

@ericjmorey you may want to try a newer version of the OCaml compiler. The current master branch of ocaml-lsp needs at least Dune 2.5 and Dune 2.5 needs at least OCaml 4.07.

@ericjmorey, despite what @hongchangwu said I still recommend you to test everything with apt install aspcud and maybe latest opam 2.0.7 or even 2.1.0~alpha3. I had similar artifacts as “no solution found” and upgrading opam helped me.

Is there a backport of the newer versions for Debian? Or do I need to build those from source. I’d much prefer to have all this handled via apt and opam package managers, but it looks like I’m down a path where everything needs to be bult from source.

You can install other compiler versions with opam, in their own switches.
For example:

opam switch create 4.07.1

You can see all available switches with opam switch list-available.
To reinstall packages in the new switch in a way that is not too painful, you can use opam switch export and opam switch import.

I’ll give that a try, but doesn’t that still leave me with an insufficient Dune version? I don’t know how to get newer compilers, I’ll do some reading on that.

I’ve decided to use Ubuntu on WSL for now, it appears to work without any of the issues above. But there’s no good reason why I can’t get OCaml Platform working on a widely used (especially in enterprise) distribution like Debian. So I’ll keep working on it.

I don’t think this is a WSL problem here, although there are some WSL/Debian quirks that don’t appear to exist with WSL/Ubuntu. WSL/OpenSUSE 15.2 on the other hand is a complete disaster that I quickly abandoned.

Thanks guys!

Had the same issue, got solved by switching to 4.11.1

Hint: opam show ocaml-lsp-server displays required version:
"ocaml" {>= "4.06" & < "4.12"}

After switching, ocaml-lsp-server installs correctly.

1 Like