Newbie stuck on a(n apparently) simple problem


I have a bog standard OCaml install, as in the Real World OCaml book.

I then installed OUnit (the unit testing framework) via opam with ‘opam install ounit’ which worked.

then I start utop and say

“open OUnit” and get an error “Error: Unbound module OUnit”

try installing ounit again, I get,

opam install ounit
[NOTE] Package ounit is already installed (current version is 2.0.8).

but utop doesn’t seem to able access it.

So as far as I can see opam is installing ounit somewhere, but otop doesn’t have it in its “searchpath”.

Do I need to explicitly set an environment variable, something like Java’s $CLASSPATH to tell programs (here utop) where to look for installed libraries?

I’m sure it is something very simple, but for the life of me, I can’t figure it out. Google isn’t much help, referring to ‘ocamlfind’ and so on as a part of building a project. I just want to load an installed library in the shell.

Thanks in advance,


You need to load the package in utop before you can open it:

#require "oUnit";;

After this open OUnit should work


Much thanks!

I did try #require “OUnit” (capital O, capital U) and it didn’t work. I’d never have guessed the correct incantation, so

Thanks again