For posterity, hoping somebody in the future finds this when they hit the same problem:
I just spent a painful ~hour trying to figure out why emacs wasn’t happy with my .ml files in a new project. I got this message in emacs when my cursor was on the first line of one of the first source files I added:
No config found for file "main.ml" in "model/bin". Try calling `dune build`.
Turns out I had to kill a running ocamlmerlin-server process, and possibly restart emacs (I did have to restart because merlin stopped working in emacs completely, possibly because of some separate problem). I wasn’t really conscious of this global state.
I suspect I got myself into this pickle by copying an existing project to set up a new project. I had changed library names in dune files but had not renamed my new .opam file. On the other hand, killing ocamlmerlin-server and restarting emacs without fixing that seems to have fixed merlin in both the old and new projects.
I’m trying to think what would have helped here. Probably in these days of LSP servers I should have thought earlier to look for a process to kill, but not knowing dune etc. well still there were a lot of other things I tried first. I think posting this may be the only change needed!
I’m not sure if this would have helped in your particular situation, but whenever I run into these kinds of merlin issues (which is fairly rarely, and usually due to copying between projects), I first try and run merlin-stop-server from within Emacs first which usually fixes the problem.
Just stumbled upon this on latest dune (3.16). IntelliSense works for normal files in my workspace (I’m using vs code), but it complains that No config found for file vendor/.../xxx.ml when the file is in vendored directory. Directory is marked with vendored_dirs stanza and contains nested dune-project inside. It used to work before I updated ocaml-lsp-server, which updated dune… @rgrinberg is this something expected? How can I troubleshoot this further?
Could you try building dune build @check or dune build @ocaml-index to generate tooling configuration and see if it fixes your issue ?
Note that it is possible (I am not sure of that fact) that Dune doesn’t generate configuration for vendored package that are not required by the host project.
This actually did the trick, thanks a lot! Not sure why I have to run it manually though, seems like some issue in my environment or a bug somewhere in the tooling.
Turns out I was editing a file, which was not built by dune. I had a file with same name in my main source tree, and I though I was editing that file, but I had opened the same file under vendored dir, and dune actually never built it, so there was no merlin configuration. Makes sense, shame on me.
dune build @ocaml-index actually tried to build everything, failed with a bunch of errors due to missing deps, but enabled the IntelliSense on that specific file. This information might still be useful for someone hitting this thread via internet search on “No config found for file”.