Error: Reference to undefined compilation unit `Build_info__Build_info_data'

Hi!

This error appeared through an issue I got here: Installation problems · Issue #401 · formalsec/smtml · GitHub .

Running #require “alt-ergo-lib” (a library that depends on dune-build-info) in utop raises the following error:

utop # #require "alt-ergo-lib";;
Error: Reference to undefined compilation unit `Build_info__Build_info_data'
Hint: This means that the interface of a module is loaded, but its implementation is not.
      Did you mean to load a compiled implementation of the module 
      using #load or by passing it as an argument to the toplevel?

However, if I run the same #require “alt-ergo-lib” inside dune utop, it succeeds.

This seems somewhat similar to this thread `Reference to undefined compilation unit` in utop , but dune-build-info doesn’t look like a virtual library to me: dune/otherlibs/dune-build-info/src/dune at main · ocaml/dune · GitHub .

Any idea what might be happening here?

While dune-build-info isn’t a virtual library, it’s in some sense even more special by invoking some dune internal magic: dune/otherlibs/dune-build-info/src/dune at 24ca148234aa4eab93dff79573ed47e79f9d7694 · ocaml/dune · GitHub.

dune utop knows how to provide an implementation of the special module just to run utop in a suitably prepared environment, but just utop does not know how to do that.

Thanks for the clarification!

So if I understand correctly:

  • dune utop sets up the environment so that the generated Build_info module is available.

  • Running plain utop doesn’t, which leads to the missing compilation unit error.

Would the right takeaway here be that libraries depending on dune-build-info can only really be used inside dune utop (or in an executable built through dune), but not in a bare utop session? Or is there a recommended way to make the generated module available to plain utop as well?