Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible syntax of ~./ocamlinit #2579

Open
yashrk opened this issue May 22, 2020 · 3 comments
Open

Incompatible syntax of ~./ocamlinit #2579

yashrk opened this issue May 22, 2020 · 3 comments

Comments

@yashrk
Copy link

yashrk commented May 22, 2020

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?

@dropofwill
Copy link

dropofwill commented Jun 30, 2020

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.

@domq
Copy link

domq commented Jan 4, 2024

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.

@apatterndarkly
Copy link

Thanks @domq!

For the lazy among us:

alias rtop="rtop -init ~/.rtopinit"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants