Is it possible to use Merlin while working on the OCaml compiler?

Is there a way to get merlin working while you’re developing on the latest version of the OCaml compiler? I tried building the compiler and installing it as an opam switch (4.08.0+local-git-trunk), but opam intstall merlin fails because the latest version of merlin is only for ocaml <= 4.07. I imagine merlin needs to be updated following each new compiler version, so is this actually just impossible?

The current git version of Merlin works reasonably well with the OCaml compiler (using a typechecker for 4.07).
If CMI file format didn’t change in OCaml trunk, Merlin should even work with it. Usually, magic numbers are updated when incompatible changes are introduced, so this should be detected at compile-time.

The easiest way to get that to work is to:

  • install a recent trunk, either in a opam switch or in a custom prefix.
  • compile merlin with this trunk
  • use this ocamlmerlin binary when working on the compiler
  • optionally: if magic number didn’t change but standard library changed (and especially Pervasives), you can point merlin to the stdlib directory of the compiler by putting STDLIB /absolute-path-to-ocaml-clone/stdlib in .merlin)

Got it working now, thanks @let-def!

Sorry to necrobump this thread. I have tried to use Merlin with the latest ocaml trunk but there is currently a hard cap in the opam resolver about the versions merlin is compatible with. So, is it safe to say that merlin now cannot be used when developing trunk, or am I missing something? thanks.

I believe the current best way to work with merlin on the compiler is to build it using dune installed with the latest released version of OCaml. This will take care of generating .merlin files, etc.

Thanks

Linking this issue as it is related (mostly for myself) https://github.com/ocaml/ocaml/pull/2093

Hey @nojb, I have opened the following issue. https://github.com/ocaml/ocaml/issues/9294 I am wondering if you know the problem. Thanks!