ocaml / ocaml-lsp

OCaml Language Server Protocol implementation
Other
753 stars 117 forks source link

"ocamllsp: -32603: dune binary not found" after ocaml update #1275

Closed qkzk closed 4 months ago

qkzk commented 4 months ago

Hello,

Sorry but I can't find much information about this problem.

My package manager updated ocaml to 5.1.1 and I had to reinstall everything with opam. Once done, my project compiles and run correctly with dune exec projectname -w.

I still have the syntax errors displayed but nothing else.

I can't jump to definition nor open a code lens.

The only message I got is ocamllsp: -32603: dune binary not found.

What should I do ?

$ ocaml -version
The OCaml toplevel, version 5.1.1

$ opam --version
2.1.5

$ which dune
/home/qkzk/.opam/5.1.1/bin/dune

$ which ocamllsp 
/home/qkzk/.opam/5.1.1/bin/ocamllsp

$ dune --version
3.15.2

From :Mason :

    ✓ ocaml-lsp ocamllsp
      OCaml Language Server Protocol implementation.

      installed version 1.17.0                             
      homepage          https://github.com/ocaml/ocaml-lsp 
      languages         OCaml                              
      categories        LSP                                
      executables       ocamllsp                           

and

Language client log: /home/qkzk/.local/state/nvim/lsp.log
 Detected filetype:   ocaml

 1 client(s) attached to this buffer: 

 Client: ocamllsp (id: 1, bufnr: [11])
    filetypes:       ocaml, ocaml.menhir, ocaml.interface, ocaml.ocamllex, reason, dune
    autostart:       true
    root directory:  /home/qkzk/gclem/dev/ocaml/tableau_noir
    cmd:             /home/qkzk/.local/share/nvim/mason/bin/ocamllsp
OS: Manjaro Linux x86_64 
Host: MS-7D09 1.0 
Kernel: 6.1.90-1-MANJARO 
Uptime: 17 hours, 33 mins 
Packages: 2429 (pacman), 4 
Shell: zsh 5.9 
qkzk commented 4 months ago

I tested a new project with :

dune init proj whatever

and the lsp works again.

I'll dig into that.

qkzk commented 4 months ago

The error is back again. I moved my whole project into a new one dune init proj same_old_thing. It worked once, it doesn't work anymore.

I'm stuck.

voodoos commented 4 months ago

Ocaml-lsp needs to run a dune process to get the project configuration. This means that dune should be present in the path. Maybe the path is not correct in neovim ?

Does this also happen if you start neovim from the terminal in the project's folder ?

qkzk commented 4 months ago

Indeed, the problem occurs when I run neovim from home then open the project. It doesn't when I run it from the project itself.

I guess this behavior is normal.

Tell me if I should close the issue.

voodoos commented 4 months ago

Yes, I would say that this is expected behavior, we cannot control the path used to run the editor. In the vscode plugin there is a handy way to select the correct opam switch from inside the editor, we would need something similar in other plugins.

qkzk commented 4 months ago

Thanks !