Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jump to definition request fails with Merlin "Several source files in your path" error #1187

Open
oleksandr-oksenenko opened this issue Sep 23, 2023 · 9 comments

Comments

@oleksandr-oksenenko
Copy link

oleksandr-oksenenko commented Sep 23, 2023

I'm trying to learn OCaml created a simple project using dune init proj, added core as a dependency and trying to go to the definition of Set in the following code:

open Core

module S = Set

let () = print_endline "Hello, World!"

and it fails with the following error:

'Locate' query to merlin returned error: File_not_found: Several source files in your path have the same name, and merlin doesn't know which is the right one: /Users/oleksandr.oksenenko/.opam/5.1.0/lib/core/set.mli, /Users/oleksandr.oksenenko/.opam/5.1.0/lib/core/set.ml, /Users/oleksandr.oksenenko/.opam/5.1.0/lib/base/set.mli, /Users/oleksandr.oksenenko/.opam/5.1.0/lib/base/set.ml, /Users/oleksandr.oksenenko/.opam/5.1.0/lib/ocaml/set.mli, /Users/oleksandr.oksenenko/.opam/5.1.0/lib/ocaml/set.ml"

I found the following issue in Merlin, however, it seems to be fixed a long time ago.

I'm using latest versions of neovim and ocaml-lsp (1.16.2) on OCaml 5.1.0, however, i encountered the same issue with 4.14.1.

Am i missing something?

@oleksandr-oksenenko oleksandr-oksenenko changed the title Merlin Locate error Jump to definition request fails with Merlin "Several source files in your path" error Sep 23, 2023
@ulugbekna
Copy link
Collaborator

@voodoos do you happen to know what could cause this?

@voodoos
Copy link
Collaborator

voodoos commented Sep 25, 2023

@oleksandr-oksenenko, thanks for the report!

Can you check if your the project has been built at least once (dune build @all) ?
Are they any error reported in the buffer ?

@oleksandr-oksenenko
Copy link
Author

@voodoos thanks for reply! Please let me know if i can provide any additional details.
The project builds and runs just fine:

~/code/ocaml_playground_2 via 🐫 v5.1.0 (5.1.0) took 16s 
❯ dune build @all
~/code/ocaml_playground_2 via 🐫 v5.1.0 (5.1.0) 
❯ dune exec -- bin/main.exe                 
Hello, World!

@voodoos
Copy link
Collaborator

voodoos commented Sep 25, 2023

Could you give me the output of ls _build/default/bin/.merlin-conf and ls _build/default/bin/.*.objs/byte ?

@oleksandr-oksenenko
Copy link
Author

The first one produces

❯ ls _build/default/bin/.merlin-conf 
exe-main

I updated the second command a bit to find what you want (i think, the dir is called .main.eobjs/):

❯ ls _build/default/bin/.*objs/byte
dune__exe__Main.cmi  dune__exe__Main.cmti

@voodoos
Copy link
Collaborator

voodoos commented Sep 25, 2023

Right, this is a usual case of "Dune @ALL target does not build cmt files for executable" (ocaml/dune#3182).

Some context: Dune generates both a configuration for Merlin and ask the compiler to write cmt files that are needed for some Merlin feature like locate. However some targets do not trigger the building of cmt files.

I think you should be good with dune build @check that is a target that explicitly ask Dune to build all merlin-needed files. (you cant check afterwards the presence of cmt files with ls _build/default/bin/.*objs/byte.

@oleksandr-oksenenko
Copy link
Author

Hm, I ran dune build @check and it fails with the same error. The contents of the byte directory:

❯ ls _build/default/bin/.main.eobjs/byte
dune__exe__Main.cmi  dune__exe__Main.cmo  dune__exe__Main.cmt  dune__exe__Main.cmti

@voodoos
Copy link
Collaborator

voodoos commented Sep 25, 2023

Right, I was able to reproduce, I will have a look. Thanks for all the information !

@oleksandr-oksenenko
Copy link
Author

Awesome, thanks!
JFYI it happens not only with core, for instance i had the same issue with cohttp modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants