Hello OCaml friends,
I have a weird Emacs-related puzzle that I was hoping you could help me with. The issue is that when I fire up a REPL using C-c C-s RET ocaml exec -- dune utop
(C-c C-s
being tuareg-run-ocaml
) in one of my dune
projects on my work machine, it loads a fully-functional OCaml REPL in comint mode that looks like this:
Yay! This is what works best for me, because I like having a project-aware REPL with completion etc. while also being able to use all the features of comint mode.
However, when my colleague does exactly the same thing on his work machine, he gets a completely unusable REPL that looks like this:
As you may be able to tell from the screenshot, that is running utop
in the form in which it would appear in a normal terminal, which is completely unsuitable for Tuareg interactive mode because of all the ANSI escape sequences, etc.
Hereās the puzzling part. I canāt tell what could be causing this. It canāt be anything in my Emacs init file, because if I fire up a fresh emacs -q /path/to/ml_file.ml
, do M-x package-initialize
, do M-x tuareg-mode
, then do C-c C-s RET opam exec -- dune utop
, I get the good comint REPL. When my colleague fires up a config-less Emacs on his machine using the same method, he gets the unusable REPL. My colleague and I have the same versions of utop
, dune
, opam
, and emacs
on our machines.
Furthermore, when I open Proced in Emacs, I see that although my REPL buffer visually resembles an old-school OCaml REPL (as opposed to an in-a-terminal utop with all of its colors, windows, and such), it is in fact running a built-by-dune-for-the-project utop
. The command itās running is:
/path/to/my/opam/switch/bin/ocamlrun /path/to/my/project/_build/default/lib/.utop/utop.bc
The PID of my buffer matches the PID of that process in Proced, which I think settles the question of whether this old school-looking thing is secretly a dune-built utop
REPL.
As a matter of pure intellectual curiosity, I would love to learn what could be causing this discrepancy. But as a matter of practicality, I would like to know how to be able to reproduce the great dev environment I have on my work machine voluntarily, rather than as a happy accident.