Utop: how to load all _build/**/*.cmo?

  1. I have a dune/ocaml project.

  2. If I run ‘dune utop’, it loads all the modules in the dune project.

  3. However, I can’t run “dune utop” while there is a “dune build -w” running.

  4. I can run a regular “utop” while there is a “dune build -w” running.

  5. From the regular utop, how do I load all of _build/**/*.cmo ? (I.e. load all modules compiled in the dune proejct).

1 Like

It looks like this bug in dune is already tracked here:

As for the question in itself, this should work fine:

#use_output "find _build/default/ -name '*.cmo' | while read x ; do echo "#load \"${x}\";;" ; done";;

Dumb followup: does *.cmo files provide type checking info? From googling around, I’m getting a message of the form:

#load “…” only loads the object file

if I actually want type checking / being able to call it from the utop REPL, I need to do something involving _directory and mli files too ?

(Just running #load “…” is NOT giving me auto completions on modules or even the module names in utop).

Ah, I think I’m starting to see the connection.

We can’t use # #use_output "dune ocaml top";; (again, due to the dune shared build issue); so we are manually trying to emulate that ?

yes exactly. Note that dune top is also a shorter alias for dune ocaml top.