ocaml command line cannot not find "topfind"

ocaml, ocaml-toplevel, opam

Solution

As stated here by samoth:

Normally this issue does not exist anymore if you are not using the system compiler. If you are using the system compiler, you can modify you ~/.ocamlinit to load $OCAML_TOPLEVEL_PATH as done in https://github.com/OCamlPro/opam/blob/master/shell/dot_ocamlinit

So you can either use a different switch or modify your `.ocamlinit`.

Problem

I have top-level installed, and have $OCAML_TOPLEVEL_PATH setup. ``` export OCAML_TOPLEVEL_PATH=/Users/smcho/.opam/system/lib/toplevel ``` I checked that the directory exists, and has one file `topfind`. This is my `~/.ocamlinit` file content. ``` #use "topfind" #camlp4o #thread #require "core.top" #require "core.syntax" ``` The issue is that I have the error message saying it can't find topfind. ``` > ocaml OCaml version 4.02.1 Cannot find file topfind. Unknown directive `camlp4o'. # ``` With "ustop", I have no error message. What might be wrong? This is my ocaml environment setup. ``` > opam config env CAML_LD_LIBRARY_PATH="/Users/smcho/.opam/system/lib/stublibs:/usr/local/lib/ocaml/stublibs"; export CAML_LD_LIBRARY_PATH; OPAMUTF8MSGS="1"; export OPAMUTF8MSGS; MANPATH=":/Users/smcho/.opam/system/man"; export MANPATH; MAKELEVEL=""; export MAKELEVEL; MAKEFLAGS=""; export MAKEFLAGS; PERL5LIB="/Users/smcho/.opam/system/lib/perl5:"; export PERL5LIB; OCAML_TOPLEVEL_PATH="/Users/smcho/.opam/system/lib/toplevel"; export OCAML_TOPLEVEL_PATH; PATH="..."; export PATH; ```

Original source