Hi everyone,
I thought I’d post a slightly arcane scenario on the off-chance that someone might be able to suggest an approach to resolving it. Please bail out when your “nonsense bingo” card is full!
merlin
I’m trying to get OCaml working in emacs under MSYS2 on a machine to which I don’t have admin access. I’m getting enormous lags (and failure) when typing in an OCaml buffer when merlin-mode
from merlin-eldoc
is enabled, even when dune build -w
is running in the project directory.
merlin-call
is getting end-of-file
when trying to parse output from ocamlmerlin
(probably because there is none).
An example merlin-debug-last-commands
value is
((("ocamlmerlin" "server" "locate" "-protocol" "sexp" "-filename" "c:/msys64/home/username/Projects/Learning/OCaml/hello/bin/main.ml" "-position" "6:23" "-look-for" "ml")
. ""))
An example (merlin-debug-last-commands)
output is
"Last commands executed, most recent at the end:
command: ocamlmerlin server locate -protocol sexp -filename c:/msys64/home/username/Projects/Learning/OCaml/hello/bin/main.ml -position 6:23 -look-for ml
- result:
command: ocamlmerlin server locate -protocol sexp -filename c:/msys64/home/username/Projects/Learning/OCaml/hello/bin/main.ml -position 6:26 -look-for ml
- result: "
ocamlmerlin
does seem to work from the shell command line, at least as ocamlmerlin single -flags-help
. I’m using fish
, hopefully that isn’t adding any complication.
I tried manually calling ocamlmerlin
with a similar command to the one implied by merlin-debug-last-commands
above (and with reference to the protocol); it seems to exit with status 1 and no output. I wonder if it could be something to do with the way paths are expressed, but couldn’t find a working combination. The following did work though:
ocamlmerlin single type-enclosing -position '1:11' -filename main.ml < bin/main.ml
returning
{"class":"return","value":[{"start":{"line":1,"col":10},"end":{"line":1,"col":11},"type":"int","tail
":"no"},{"start":{"line":1,"col":10},"end":{"line":2,"col":7},"type":"int -> int -> int","tail":"no"
}],"notifications":[],"timing":{"clock":228,"cpu":0,"query":0,"pp":0,"reader":0,"ppx":0,"typer":0,"e
rror":0},"heap_mbytes":0,"cache":{"reader_phase":"miss","ppx_phase":"miss","typer":"miss","cmt":{"hi
t":1,"miss":1},"cmi":{"hit":0,"miss":1}},"query_num":0}
Changing single
to server
caused there to be no output, and exit code 1. Changing server
to single
in merlin.el
didn’t work (still end-of-file
like original problem). It feels like either I’m not calling ocamlmerlin server
correctly, or there’s some ?platform reason it’s not returning anything.
tuareg
I also got a build error with tuareg which I worked around; I’m not sure whether it’s relevant to the above problem.
I installed OCaml with winget, which was great. I installed emacs within MSYS2, which worked. opam install tuareg
failed with Error: buffer-read-only when processing tuareg-site-file.el
. There is no obvious permissions problem with that file. I looked at tuareg’s Makefile, and found this:
$(EMACS) --batch --eval '(if (>= emacs-major-version 28) (make-directory-autoloads "." "'`pwd`'/$@") (setq generated-autoload-file "'`pwd`'/$@") (batch-update-autoloads))' "."
(In elisp (if COND THEN ELSE...)
apparently evaluates all ELSE
s and returns the last, if COND
yields nil
.)
I ran the emacs line manually and got the same error, plus Package autoload is deprecated
.
In any case, re-running the tuareg installation “worked”, presumably because a tuareg-site-file.el
was generated, and therefore that Makefile
stanza didn’t re-run.
Tuareg does seem to work, so again I’m not sure this is relevant to my merlin problem.
so…
Thanks for reading this far. I’d love to try any suggestions you may have.