I am on macOS 13.4, I set up my Ocaml environment with emacs but I'm still new at it so I got trouble solving some of my problems:
For the project I am working on I had to clone my working repository twice. The first repository works fine: merlin recognises the modules, I can C-c C-l
to access the definition of objects, and the execution of the code C-x C-e
works fine.
Dependencies:
- merlin toolkit v4.5-412
- opam v2.1.4
- dune v3.8.0
- ocaml toplevel v4.12.1
Merlin doesn't seem to work in my second repository: the libraries installed, such as Irmin or Lwt aren't recognized, they are Not in environment
when I try C-c C-l
. Every call to the libraries shows the error Unbound module ...
.
Then I can't manage to execute the code with the opam switch of my second repository:
opam exec --switch=/Users/Louis/git/temp/learn-ocaml -- ocaml
in emacs returns the error
error "Buffer *OCaml* has no process"
I tried to solve the problem:
eval $(opam env)
and then M-x merlin-stop-server RET
in emacs but I have the error
No config found for irmin-test.ml. Try calling `dune build`.
I also get the error message, when I try to save a file:
The current Merlin configuration has been generated by another, incompatible, version of Dune. Please rebuild the project. (Using the same version of Dune as the one running the `ocaml-merlin` server.)
The dependencies used for compilation should be alright, and I made sure all the opam packages were installed.
I also tried to set the switch manually:
eval $(opam env --switch=/Users/Louis/git/temp/learn-ocaml --set-switch)
but it tells me
[ERROR] The selected switch /Users/Louis/git/temp/learn-ocaml is not installed.
To select a switch1 in Emacs within the Tuareg mode, use the
tuareg-opam-update-env
command, e.g.,M-x tuareg-opam-update-env
. It will allow you to select a switch, including local switches.Once a switch is selected, make sure that your project (the code that you're developing) is rebuilt. You can issue
dune build
command, or, if you just want to get Merlin work, thendune build @check
will suffice.Last, but not least, the error message,
indicates that you're specifying the path to the switch incorrectly or your switch is not properly installed. Try re-installing it from scratch paying attention to any error messages (there should be none of them).
1) I presume that by repository you mean an opam switch -- an installation of a compiler together with packages.