Error running Ocaml Merlin on Atom

I recently installed Opam, OCaml, and Merlin on my WSL (Ubuntu) with the intention of writing OCaml code in Atom. On Atom, I installed the ocaml-merlin package and all of its requisite Atom packages. When editing my OCaml file in Atom however, I keep getting an error that says [Linter] Error running OCaml Merlin , and opening the console displays these errors:

Merlin process started, pid = undefined
C:\Users\Ro\.atom\packages\ocaml-merlin\lib\merlin.coffee:38 Error: spawn ocamlmerlin ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:232)
    at onErrorNT (internal/child_process.js:407)
    at process._tickCallback (internal/process/next_tick.js:63)
2internal/stream_base_commons.js:78 Uncaught (in promise) Error: write EPIPE
    at afterWriteDispatched (internal/stream_base_commons.js:78)
    at writeGeneric (internal/stream_base_commons.js:73)
    at Socket._writeGeneric (net.js:713)
    at Socket._write (net.js:725)
    at doWrite (_stream_writable.js:410)
    at writeOrBuffer (_stream_writable.js:394)
    at Socket.Writable.write (_stream_writable.js:294)
    at Interface._writeToOutput (readline.js:300)
    at Interface.prompt (readline.js:264)
    at Interface.question (readline.js:277)
    at /C:/Users/Ro/.atom/packages/ocaml-merlin/lib/merlin.coffee:42
    at new Promise (<anonymous>)
    at /C:/Users/Ro/.atom/packages/ocaml-merlin/lib/merlin.coffee:40
C:\Users\Ro\.atom\packages\linter\lib\linter-registry.js:154 [Linter] Error running OCaml Merlin Error: write EPIPE
    at afterWriteDispatched (internal/stream_base_commons.js:78)
    at writeGeneric (internal/stream_base_commons.js:73)
    at Socket._writeGeneric (net.js:713)
    at Socket._write (net.js:725)
    at doWrite (_stream_writable.js:410)
    at writeOrBuffer (_stream_writable.js:394)
    at Socket.Writable.write (_stream_writable.js:294)
    at Interface._writeToOutput (readline.js:300)
    at Interface.prompt (readline.js:264)
    at Interface.question (readline.js:277)
    at /C:/Users/Ro/.atom/packages/ocaml-merlin/lib/merlin.coffee:42
    at new Promise (<anonymous>)
    at /C:/Users/Ro/.atom/packages/ocaml-merlin/lib/merlin.coffee:40

I definitely have Merlin installed, and issuing which ocamlmerlin on the WSL terminal returns /home/ro/.opam/4.09.0/bin/ocamlmerlin , so I believe this means that it’s on the PATH already?

If it’s relevant, my OCaml version is 4.09.0 and my Merlin version is 73e9771b, for Ocaml 4.09.0 .

After many hours of poking around the internet for a solution, I saw that a possible issue could be that I don’t have a .merlin file at the root of my directory. I’m not sure how to confirm this is the issue or how to remedy it if that is the case. I’ve also seen that Dune creates an .merlin file for you, but I’m not using Dune (although I believe I have it installed). Calling the OCaml compiler directly in lieu of using Dune has been working just fine for me, so I don’t particularly care to start using Dune.

If any of you know what the issue could be and how to fix it, I would greatly appreciate any help. Thank you :orange_heart:

Are you launching Atom through the shell that has the PATH set or are you launching it in some other way?

I’m launching it from Windows just by clicking Atom. Launching Atom from WSL on both the Windows and Ubuntu file systems gives me the same error anyways.

If it means anything, I just tried using this script to generate a .merlin file since I didn’t have one. I have a .merlin file in my root directory now, and I’m still having the same issue. If the .merlin file is problematic, then maybe I should try using Dune to generate a .merlin file instead? Not sure how to do that though. I’m not sure if that will be a viable solution either.

The problem if I see it correctly is that the plugin you’re using can’t start the ocamlmerlin binary, which is entirely independent from finding .merlin files.

The path to the binary is usually set via OPAM in the terminal, so my recommendation is to launch your editor from a shell where the PATH variable is set correctly. If you launch Atom from the menu it can’t know where to find ocamlmerlin.

Ah yeah, I checked what paths show up in PowerShell using the $Env:Path command and .opam doesn’t even show up, so ocamlmerlin can’t be on the path in the Windows side of the file system.
I’ll try launching Atom from WSL again and see if it works. If I open the file that I’m coding in from Windows, then I can access the file properly and all of my code is in there, but if I open the file from the Ubuntu file system side then my file is empty, so I’m not sure if I’ll be interfering with anything. Thank you for helping!