0

I've been using VSC on my MacBook Pro, but recently when I open .ml files in VSC I have started getting a message in the lower right-hand corner of the window that says "Cannot find merlin binary at 'ocamlmerlin'." Additionally, in Output I get the following:

Error: spawn ocamlmerlin ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn ocamlmerlin',
  path: 'ocamlmerlin',
  spawnargs: []
}
[Error - 4:35:35 PM] Connection to server got closed. Server will not be restarted.

I've also noticed that the red squiggly lines that identify coding errors have stopped appearing. Has anyone else seen this type of error before with VSC?

  • 2
    `ocamlmerlin` is one of the language servers that can provide language support for OCaml, and if it's no longer there, that's a problem. VSCode doesn't use language servers directly though, extensions do. So the question then is, which OCaml language extension(s) do you use? And how do you manage your ocaml isntallation and packages? Did you do something recently that could have removed `ocamlmerlin`? Such as removing opam, using a different `opam switch`, or not running `eval $(opam env)` anymore? If using `opam`, what does `opam switch` and `opam list` say? And `which ocamlmerlin`? – glennsl Oct 02 '21 at 20:55
  • It looks like the extension I'm using is OCaml and Reason IDE. I think I did make some changes a few weeks back because I was having some trouble with a module I'm using (CS51Utils), but unfortunately I can't remember exactly what I did. `which ocamlmerlin` outputs `ocamlmerlin not found`. `opam switch` shows two ocaml base compilers (4.11.1 and 4.12.0) and shows 4.12.0 as the default. – Ash Ketchum Oct 03 '21 at 02:56
  • 1
    I think that's the most outdated of the extensions, but it should probably still work if you `opam install merlin`. The current recommended extension seems to be OCaml platform. I don't use vscode, so my knowledge here is very limited. – glennsl Oct 03 '21 at 08:07
  • `opam install merlin` seems to have done the trick. Thank you! – Ash Ketchum Oct 04 '21 at 15:24

1 Answers1

0
  1. Depending on your platform, the user settings file for vs code is located here:

Windows %APPDATA%\Code\User\settings.json.

macOS /Users/<YOUR-HOME-DIRECTORY>/Library/Application Support/Code/User/settings.json.

Linux $HOME/.config/Code/User/settings.json.

  1. Open the file settings.json and paste the following inside:
{
    "ocaml.merlinPath": "/Users/nick/.opam/system/bin/ocamlmerlin",
    "reason.path.ocamlmerlin": "/Users/<YOUR-HOME-DIRECTORY>/.opam/system/bin/ocamlmerlin"
}
glennsl
  • 28,186
  • 12
  • 57
  • 75
BigHero101
  • 11
  • 1
  • 3