Desired Behavior
dune exec is an useful command for running binaries and making sure that the binaries that are run are up-to-date (thus preferable to dune build followed by _build/default/install/bin/...). However in my experience it is unnecessarily strict on what inputs it accepts when it could (in my opinion) fairly reasonably infer what the user wants to do in a number of common cases.
dune exec currently requires a target to execute. However, the notion of targets is somewhat confusing for users because unlike make Dune does not put targets in the source tree. At the moment to execute a binary dune exec can take a public name (which is fairly ergonomic and straightforward) but it can also be used to launch executables by means of dune exec bin/main.exe.
Unfortunately, bin/main.exe does not exist in the source tree thus naive command line completion does not suggest it. Furthermore, the user needs to be aware of the fact that even on Unix the target has an .exe suffix. Thus lowering the chances of the user succeeding in figuring this out and remembering this for the future to a low percentage. Back in the day it was easier for me to call dune build && _build/.../binary.exe since it was more understandable what is happening and this might be similar to other users.
@Alizter mentioned that it is also possible to pass pforms to dune exec, however I think the ergonomics of an user typing dune exec %{bin:foo} is potentially even worse than typing in the target manually.
Example
builds and executes foo automatically.
Unlike dune build bin/foo.ml this does not conflict with copying code from the source tree into the build folder as the user has expressed that they want to execute a process.
Desired Behavior
dune execis an useful command for running binaries and making sure that the binaries that are run are up-to-date (thus preferable todune buildfollowed by_build/default/install/bin/...). However in my experience it is unnecessarily strict on what inputs it accepts when it could (in my opinion) fairly reasonably infer what the user wants to do in a number of common cases.dune execcurrently requires a target to execute. However, the notion of targets is somewhat confusing for users because unlikemakeDune does not put targets in the source tree. At the moment to execute a binarydune execcan take a public name (which is fairly ergonomic and straightforward) but it can also be used to launch executables by means ofdune exec bin/main.exe.Unfortunately,
bin/main.exedoes not exist in the source tree thus naive command line completion does not suggest it. Furthermore, the user needs to be aware of the fact that even on Unix the target has an.exesuffix. Thus lowering the chances of the user succeeding in figuring this out and remembering this for the future to a low percentage. Back in the day it was easier for me to calldune build && _build/.../binary.exesince it was more understandable what is happening and this might be similar to other users.@Alizter mentioned that it is also possible to pass pforms to
dune exec, however I think the ergonomics of an user typingdune exec %{bin:foo}is potentially even worse than typing in the target manually.Example
(executable (name foo))$ dune exec bin/foo.mlbuilds and executes
fooautomatically.Unlike
dune build bin/foo.mlthis does not conflict with copying code from the source tree into the build folder as the user has expressed that they want to execute a process.