# Troubleshooting LSP server & VS Code extension

**URL:** <https://discuss.ocaml.org/t/troubleshooting-lsp-server-vs-code-extension/8492>\
**Category:** Learning\
**Tags:** ocaml-lsp-server, vscode, dune\
**Created:** [September 15, 2021, 11:06am UTC](https://discuss.ocaml.org/t/troubleshooting-lsp-server-vs-code-extension/8492 "2021-09-15T11:06:58Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Konstantin\_Olkhovski](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/konstantin_olkhovski/32/1494_2.png) [@Konstantin\_Olkhovski](https://discuss.ocaml.org/u/Konstantin_Olkhovski)\
**Post date:** [September 15, 2021, 11:06am UTC](https://discuss.ocaml.org/t/troubleshooting-lsp-server-vs-code-extension/8492/1 "2021-09-15T11:06:58Z")

</div>

Is there some guide on how to troubleshoot LSP server with VS code extension?

In one of my projects (ppx), vs code is unable to show most of the types, complains about ppxlib.metaquot extension points being unknown, etc. It works fine on other projects and I’m trying to figure out what’s the issue here. Project in question builds just fine, has local switch (like other projects do), `dune clean && dune build` with consecutive restart of LSP server does not seem to change anything.

ocaml-lsp-server 1.4.1  
dune 2.8.2  
OCaml Platform v1.8.4

---

<div class="post-metadata">

**Author:** ![rbjorklin](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/rbjorklin/32/1126_2.png) [@rbjorklin](https://discuss.ocaml.org/u/rbjorklin)\
**Post date:** [September 15, 2021, 6:44pm UTC](https://discuss.ocaml.org/t/troubleshooting-lsp-server-vs-code-extension/8492/2 "2021-09-15T18:44:30Z")

</div>

I’m not qualified to help but can you reproduce the issue with the latest version of [ocaml-lsp-server](https://github.com/ocaml/ocaml-lsp/releases/tag/1.8.2)?

---

<div class="post-metadata">

**Author:** ![rgrinberg](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/rgrinberg/32/40_2.png) [@rgrinberg](https://discuss.ocaml.org/u/rgrinberg)\
**Post date:** [September 15, 2021, 7:52pm UTC](https://discuss.ocaml.org/t/troubleshooting-lsp-server-vs-code-extension/8492/3 "2021-09-15T19:52:38Z")

</div>

And also update to the latest version of:

- dot-merlin-reader
- ppxlib
- dune

It’s a real shame that this corner of tooling has so many moving parts. I’m well aware of frustrating it can be for users and always on the look out on how to simplify this.

---

<div class="post-metadata">

**Author:** ![Konstantin\_Olkhovski](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/konstantin_olkhovski/32/1494_2.png) [@Konstantin\_Olkhovski](https://discuss.ocaml.org/u/Konstantin_Olkhovski)\
**Post date:** [September 16, 2021, 12:38pm UTC](https://discuss.ocaml.org/t/troubleshooting-lsp-server-vs-code-extension/8492/4 "2021-09-16T12:38:13Z")

</div>

I’ve updated dot-merlin-reader and dune to versions 4.1 and 2.9.1 correspondingly.

I can’t easily update LSP server as it tries to pull in OCaml 4.12 `ocaml-lsp-server >= 1.5.0 → ocaml >= 4.12`, project is using 4.08 currently. Also I can’t update ppxlib as it requies Jane Street libs 0.14, the project is using 0.13…

The problem is still there. Is there any way to troubleshoot this? Some logs maybe? Something should be wrong in my environment.

---

<div class="post-metadata">

**Author:** ![Konstantin\_Olkhovski](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/konstantin_olkhovski/32/1494_2.png) [@Konstantin\_Olkhovski](https://discuss.ocaml.org/u/Konstantin_Olkhovski)\
**Post date:** [September 16, 2021, 3:46pm UTC](https://discuss.ocaml.org/t/troubleshooting-lsp-server-vs-code-extension/8492/5 "2021-09-16T15:46:28Z")

</div>

Actually things work ouf of the box for my colleague with the following versions:

```auto
dune 2.9.0
dot-merlin-reader 4.1
ppxlib 0.13.0
ocaml-lsp-server 1.4.1
vscode 1.57.1
ocaml platform 1.8.4

```

I have about the same:

```auto
dune 2.9.1
dot-merlin-reader 4.1
ppxlib 0.13.0
ocaml-lsp-server 1.4.1
vscode 1.60.0
ocaml platform 1.8.4

```

Something is wrong with my setup but I don’t know how to debug this.

---

<div class="post-metadata">

**Author:** ![rgrinberg](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/rgrinberg/32/40_2.png) [@rgrinberg](https://discuss.ocaml.org/u/rgrinberg)\
**Post date:** [September 16, 2021, 4:03pm UTC](https://discuss.ocaml.org/t/troubleshooting-lsp-server-vs-code-extension/8492/6 "2021-09-16T16:03:18Z")

</div>

Do you have some weird paths in your project? E.g. containing spaces for example.

---

<div class="post-metadata">

**Author:** ![Konstantin\_Olkhovski](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/konstantin_olkhovski/32/1494_2.png) [@Konstantin\_Olkhovski](https://discuss.ocaml.org/u/Konstantin_Olkhovski)\
**Post date:** [September 16, 2021, 4:08pm UTC](https://discuss.ocaml.org/t/troubleshooting-lsp-server-vs-code-extension/8492/7 "2021-09-16T16:08:33Z")

</div>

Path is perfectly obvious, `-` is the most interesting character used in folder names, overall length is 32 symbols. Projects in the same parent folder work just fine.

I noticed one weird thing though - when selecting sandbox the list of options includes an esy sandbox for my project, along with opam one. I tried esy on this project long time ago, and revertedit back to opam workflow, but this menu item is still there in vs code, although I don’t have any esy specific files in the project. I select opam sandbox though.

---

<div class="post-metadata">

**Author:** ![vds](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/vds/32/2013_2.png) [@vds](https://discuss.ocaml.org/u/vds)\
**Post date:** [September 17, 2021, 9:12am UTC](https://discuss.ocaml.org/t/troubleshooting-lsp-server-vs-code-extension/8492/8 "2021-09-17T09:12:59Z")

</div>

Is the project you work on publicly available ? It would be easier to give you debugging directions if we knew more about it.

You can try, after running `dune build` to query merlin manually and check that the configuration is correct:

`ocamlmerlin single dump-configuration -filename some_source.ml < path/to/some_source.ml`

---

<div class="post-metadata">

**Author:** ![Konstantin\_Olkhovski](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/konstantin_olkhovski/32/1494_2.png) [@Konstantin\_Olkhovski](https://discuss.ocaml.org/u/Konstantin_Olkhovski)\
**Post date:** [September 17, 2021, 9:28am UTC](https://discuss.ocaml.org/t/troubleshooting-lsp-server-vs-code-extension/8492/9 "2021-09-17T09:28:43Z")

</div>

Unfortunately the project is a proprietary codebase. To make things more interesting - source file is in ReasonML. What would be the command for ReasonML source file?

---

<div class="post-metadata">

**Author:** ![Konstantin\_Olkhovski](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/konstantin_olkhovski/32/1494_2.png) [@Konstantin\_Olkhovski](https://discuss.ocaml.org/u/Konstantin_Olkhovski)\
**Post date:** [September 17, 2021, 9:35am UTC](https://discuss.ocaml.org/t/troubleshooting-lsp-server-vs-code-extension/8492/10 "2021-09-17T09:35:35Z")

</div>

Looks like ReasonML sources just work out of the box (which is awesome!), I’ve glanced at config and noticed some weird thing - in `.ocaml.ppx[0]` `workdir` seems correct, but `workval` references ppx.exe from another project somehow? Why is that?  
I also see the following on stderr:  
`sh: 1: /home/vagrant/git/microservices/other-project/_build/default/.ppx/6c576912eb9e97e8b9374cad21f986b5/ppx.exe: not found`

This definitely looks wrong but I’m not sure where from this can come.

---

<div class="post-metadata">

**Author:** ![Konstantin\_Olkhovski](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/konstantin_olkhovski/32/1494_2.png) [@Konstantin\_Olkhovski](https://discuss.ocaml.org/u/Konstantin_Olkhovski)\
**Post date:** [September 17, 2021, 10:03am UTC](https://discuss.ocaml.org/t/troubleshooting-lsp-server-vs-code-extension/8492/11 "2021-09-17T10:03:08Z")

</div>

`merlin.build_path` and `merlin.source_path` also list a bunch of folders from another project. Opam switch that I use is local one, `opam switch` tells me that the current switch is located in my current project folder, yet merlin gets other project from somewhere.

---

<div class="post-metadata">

**Author:** ![Konstantin\_Olkhovski](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/konstantin_olkhovski/32/1494_2.png) [@Konstantin\_Olkhovski](https://discuss.ocaml.org/u/Konstantin_Olkhovski)\
**Post date:** [September 17, 2021, 10:07am UTC](https://discuss.ocaml.org/t/troubleshooting-lsp-server-vs-code-extension/8492/12 "2021-09-17T10:07:58Z")

</div>

I’ve removed the local switch in another project along with `_build` directory, but it is still being referenced in the project that has the issue. I’m using opam 2.1 if that matters.

---

<div class="post-metadata">

**Author:** ![Konstantin\_Olkhovski](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/konstantin_olkhovski/32/1494_2.png) [@Konstantin\_Olkhovski](https://discuss.ocaml.org/u/Konstantin_Olkhovski)\
**Post date:** [September 17, 2021, 10:14am UTC](https://discuss.ocaml.org/t/troubleshooting-lsp-server-vs-code-extension/8492/13 "2021-09-17T10:14:51Z")

</div>

Okay, I managed to resolve this. When I vendored my current project (which is a library) into another project (which is a service) via a symlink, something created .merlin files right in the source tree. As I had those .gitignore’d, `git status` didn’t show me those when I was checking for extra files being left somewhere. Those .merlin files were referencing that another project, this is highly confusing and hard to debug… I’ve removed those and now things are back to normal. Thanks @vds for configuration pointer, that really helped.
