Error with merlin + emacs + jbuilder

merlin

#1

I launch Emacs on a Mac and open a file that lives in a project built by jbuilder (so thus jbuilder creates the .merlin). I get this:

Starting merlin instance: default (binary=/Users/ashish/.opam/4.03.0/bin/ocamlmerlin).
selected directory: "/Users/ashish/foo/"
Error in merlin/send-command-async callback: (error "Command ((assoc) (document auto /Users/ashish/foo/foo.mli) (query protocol version 3)) failed with error nil")
Error in merlin/send-command-async callback: (error "Command ((assoc) (document auto /Users/ashish/foo/foo.mli) (query tell start end
... full content of file ...
)) failed with error nil")

I can’t reproduce the problem on a small test case, so having trouble debugging. Do the above errors give anyone an idea of what I should look into?

I found merlin#457, which IIUC suggests the issue is with a mismatch between the emacs merlin package and the ocamlmerlin binary. However, I’m loading the emacs files that get installed within my opam switch, so that should be in sync with the binary.


#2

I seemed to getting this error too. I did have Merlin working just fine last night, and running which ocamlmerlin using M-x shell-command gives me the correct path to the merlin binary, so I can’t tell what’s wrong.


#3

This seems to be a weird Heisenbug that’s just disappeared for me, for no obvious reason. I’m seeing a different error now in files making heavy use of Jane Street PPX rewriters:

Merlin failed with error: "Error while running external preprocessor
Command line: ../_build/default/.ppx/ppx_jane/ppx.exe --as-ppx --cookie 'library-name=conveyance' '/var/folders/px/knyrxd_d3wb4220y4j7cmkg40000gn/T/camlppx8a5508' '/var/folders/px/knyrxd_d3wb4220y4j7cmkg40000gn/T/camlppxf8d2f4' 1>/dev/null 2>/dev/null"

#4

After playing around with different OCaml files I think the problem is that if Merlin encounters errors (such as with the one described above) it confuses the integration on the Spacemacs making the Merlin unusable, but only for that buffer. I’m not sure if there is a way to fix this other than better integration between the two sides, and better handling of things like PPX rewriters.