Hi, I'm currently updating my Dune introduction article with Dune v1.0.1 from Jbuilder 1.0+beta19. I noticed there is a different behavior in dune exec command.
The simplest example would be the hello world example from the docs. Previously with jbuilder, the following works:
$ jbuilder build hello_world.exe
$ jbuilder exec hello_world.exe
Hello, world!
However, with Dune:
$ dune build hello_world.exe
$ dune exec hello_world.exe
Error: Program "hello_world.exe" not found!
As noted in the docs, it works if we use dune exec ./hello_world.exe.
However, if we move the dune and hello_world.ml files to a directory, say bin, the following works:
$ mkdir bin
$ mv dune hello_world.ml bin/
$ dune clean
$ dune exec bin/hello_world.exe
Hello, world!
I thought it should also be dune exec ./bin/hello_world.exe (although this works too). I was wondering if this distinction is intentional.
The criterion is the same as in a shell:
/ is searched in the path/ is considered as a filename relative to the current directoryThe old behavior wasn't intentional. That said, maybe we could always add the current directory to the search path.
I see, so the current behavior is the desired one? An issue that I think may happen is that things will break if people depend on the previous behavior in their build scripts (and not using the alias, e.g. @install).
Yes. However, AFAIR we never discussed the possibility of allowing dune exec hello.exe. Allowing it seems fine to me.
To be honest, I'd rather us error in this case and give the user a useful suggestion. Keeping the semantics clear seems much more important to me.
I discussed with @emillon and if everyone agrees with that solution I am going to work on adding some useful hints for the misled users.
Most helpful comment
To be honest, I'd rather us error in this case and give the user a useful suggestion. Keeping the semantics clear seems much more important to me.