Dune and custom utop

I’m trying to get dune to create an executable custom utop that will install with the project/package I’m working on. I’ve been banging my head against the wall trying to get this to work. I know how to do this with ocamlfind and ocamlmktop and I could just create a Makefile that dune runs but I’m pretty sure I’m just missing something simple. I followed the utop README.md and it compiles and creates the executable but it is just the regular utop without the libs. I tried fiddling with the simple example in the github repo but I end up with the same result.

Have you tried dune utop while in your project root? More docs here: Command-line interface — dune documentation

(Note that the <dir> argument is optional)

1 Like

Sounds like you want the toplevel stanza Stanza reference — dune documentation. However note that this stanza builds vanilla toplevels, not utop ones.

Cheers,
Nicolas

1 Like

I use dune utop all the time. I’m trying to create an executable that can be installed. That dune utop can do this within the root of a project means the tooling in dune already exists. I checked out the toplevel stanza but I couldn’t figure out how to make that an executable. To be fair I didn’t try too hard with this option as I’d like the completion etc. Thank you both for your suggestions.

Oh I see, sorry for misunderstanding.

I don’t have much experience with this, FYI but utop is a bytecode program, not a native executable. While it might be possible to bundle it with some extra libraries pre-loaded, the result would still depend on ocamlrun.

Thank you. Yes, I’m aware that it would be bytecode. My objective is to have the custom toplevel installed with the library. So when you use opam to install it you get this toplevel on your path. I’ve check out the source of a project I know that does this and they are using the hybrid dune/Makefile approach I mentioned.