reason
reason copied to clipboard
Incompatible syntax of `~./ocamlinit`
After installing utop with opam I have the following ~/.ocamlinit:
(* ## added by OPAM user-setup for ocamltop / base ## 3ec62baf6f9c219ae06d9814069da862 ## you can edit, but keep this line *)
#use "topfind";;
(* ## end of OPAM user-setup addition for ocamltop / base ## keep this line *)
With this ~/.ocamlinit my rtop unsurprisingly fails with
Fatal error: exception File ".ocamlinit", line 1, characters 3-5:
Error: Unclosed "(" (opened line 1, column 0)
But if I replace default ~/.ocamlinit with
#thread;
#require "core";
open Core;
as suggested at https://reasonml.chat/t/rtop-and-ocamlinit-syntax-errors-and-confusion/1813, this (also unsurprisingly) breaks utop:
File ".ocamlinit", line 1, characters 7-8:
1 | #thread;
^
Error: Syntax error
Can rtop use something like ~/.reasonmlinit or (preferrably) use ~/.ocamlinit converted on-the-fly with refmt?
Running into this as well. Interestingly rtop does seem to generate ~/.reasoninit:
/* Added by rtop */
let () =
try (Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH")) {
| Not_found => ()
};
But it still tries to load the ~/.ocamlinit and fails because of the same syntax errors you posted.
EDIT: looks like maybe the reasoninit file was left from an older install, I can't find any refs to it in the current rtop, but its there in the history.
The ~/.ocamlinit value appears to be hard-coded in uTop's source code. We should probably create an issue there.
A workaround is to call rtop -init ~/.rtopinit in a wrapper shell script.