# Error with merlin + emacs + jbuilder

**URL:** https://discuss.ocaml.org/t/error-with-merlin-emacs-jbuilder/429
**Category:** Ecosystem
**Tags:** merlin
**Created:** [June 16, 2017, 5:50pm UTC](https://discuss.ocaml.org/t/error-with-merlin-emacs-jbuilder/429 "2017-06-16T17:50:46Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ashish](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/ashish/32/34_2.png) [@ashish](https://discuss.ocaml.org/u/ashish)
#### Post date: [June 16, 2017, 5:50pm UTC](https://discuss.ocaml.org/t/error-with-merlin-emacs-jbuilder/429/1 "2017-06-16T17:50:46Z")

</div>

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:

```auto
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](https://github.com/ocaml/merlin/issues/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.

---

<div class="post-metadata">

### Author: ![basus](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/basus/32/29_2.png) [@basus](https://discuss.ocaml.org/u/basus)
#### Post date: [June 27, 2017, 3:44pm UTC](https://discuss.ocaml.org/t/error-with-merlin-emacs-jbuilder/429/2 "2017-06-27T15:44:07Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![basus](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/basus/32/29_2.png) [@basus](https://discuss.ocaml.org/u/basus)
#### Post date: [June 27, 2017, 5:16pm UTC](https://discuss.ocaml.org/t/error-with-merlin-emacs-jbuilder/429/3 "2017-06-27T17:16:05Z")

</div>

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:

```auto
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"

```

---

<div class="post-metadata">

### Author: ![basus](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/basus/32/29_2.png) [@basus](https://discuss.ocaml.org/u/basus)
#### Post date: [June 27, 2017, 5:37pm UTC](https://discuss.ocaml.org/t/error-with-merlin-emacs-jbuilder/429/4 "2017-06-27T17:37:03Z")

</div>

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.
