Dune: Change in `dune exec` incantation

Created on 3 Aug 2018  路  5Comments  路  Source: ocaml/dune

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.

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.

All 5 comments

The criterion is the same as in a shell:

  • a command name without / is searched in the path
  • a command name with at least one / is considered as a filename relative to the current directory

The 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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vsiles picture vsiles  路  7Comments

ShengChen picture ShengChen  路  5Comments

bobot picture bobot  路  7Comments

kyldvs picture kyldvs  路  7Comments

rgrinberg picture rgrinberg  路  6Comments