OCaml: Unbound module Core with ~/.ocamlinit setup

2019-08-17 06:45发布

问题:

I have installed a few packages using opam, such as Core and Batteries. The ocamlinit file is as follows:

(* Added by OPAM. *)

#use "topfind"
#thread
#camlp4o
#require "core.top"
#require "core.syntax"
#require "batteries"

let () =
  try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH")
  with Not_found -> ()
;;

When I run this with utop I can see the modules for Batteries but I cannot see any of the modules for Core. When I try to do open Core or open Core.Std I get an unbound module error. I also tried adding in #require "core" and the error persisted.

I'm not sure what the error is since I followed the installation instructions from the book "Real World OCaml".

I also see two messages when I start off utop:

No such package: oUnit" - required by `pa_ounit'"
No such package: pa_pipebang" - required by `core.syntax'"

I'm not sure if these are related to the problem but when I do opam list ounit and opam list pipebang it shows them as installed.

回答1:

Ok, I made a fresh install of OCaml and I found out that the problem is indeed related to

No such package: oUnit" - required by `pa_ounit'"
No such package: pa_pipebang" - required by `core.syntax'"

What happened was when I tried to opam install yojson async an error occurred. From that point onward Core didn't load properly.

So I suppose something is wrong with the installation instructions on 'Real World OCaml' for the additional libraries.



标签: ocaml opam