-
Notifications
You must be signed in to change notification settings - Fork 464
Description
Desired Behavior
This follows on from the discussion on discourse: Request for feedback about a proper way to auto-require packages
Currently, dune provides commands to automatically setup a toplevel for a project when it consists of one or more libraries, with commands like dune top returning the sequence of directives to import the external libraries used in the project, dune utop starting a utop instance with all the libraries used in the project preloaded.
When the dune project only contains an executable, these commands do not work as expected, and do nothing: dune top returns an empty sequence of directives, and dune utop starts a utop instance with no additional libraries loaded.
The user interface of tools like dune top and dune utop would be improved if they behaved consistently, irrespective of the particular structure of the dune project (only executable, libraries etc.).
Edit: following on from further discussions on discuss.ocaml.org, @rgrinberg mentioned that loading executable files may run side-effects that the user may not want - as a workaround to still provide a consistent experience to the user, it would be good if dune still loaded the external libraries used by the executable, and only loaded the executable itself if requested by the user.
Example
Given a dune project as follows:
(executable
(name example)
(libraries containers))
Running dune top should return:
$ dune top
#directory "/home/<user>/.opam/4.12.0/lib/containers";;
#load "/home/<user>/.opam/4.12.0/lib/containers/monomorphic/containers_monomorphic.cma";;
#load "/home/<user>.opam/4.12.0/lib/containers/containers.cma";;
Note that the directives above don't load the executable itself thereby avoiding any side-effects that the executable may have run. The user can then separately explicitly request the executable be loaded by passing an additional flag --load-executables