Issue with minimal .ocamlinit from Real World Ocaml

Hi,

Following the installation and setup instructions for ocaml tool chain from Real World Ocaml book.
An issue arise after setting up utop, the .ocamlinit containing :

#require "core.top";;
#require "ppx_jane";;
open Base;;

cause an error when ocaml interactive shell start :

~$ ocaml
        OCaml version 4.13.1

Unknown directive `require'.
# 

Since any issue arise before, I don’t think I’ve forgotten some steps.
I can provide more information if needed.
Any advice will be appreciated, thanks in advance !

Cheers

1 Like

#require is a top-level instruction from ocamlfind which is loaded by utop but not by the ocaml top-level (by default). The error should thus go away if you try starting utop instead.

You can also add the below as a first line to ~/.ocamlinit if you want this to work under the ocaml top-level too:

#use "topfind";;
3 Likes

Ok, I’ve investigated more on utop, and I’ve decided to create an init.ml file for utop and remove the content of .ocamlinit.
I will follow the Book with utop repl.
Thanks a lot

Bye

What was the error you had with utop? You’ll typically have a much smoother experience working through RWO with utop instead of the vanilla OCaml toplevel.