Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change in dune exec incantation #1094

Closed
bobbypriam opened this issue Aug 3, 2018 · 5 comments · Fixed by #3041 or ocaml/opam-repository#15795
Closed

Change in dune exec incantation #1094

bobbypriam opened this issue Aug 3, 2018 · 5 comments · Fixed by #3041 or ocaml/opam-repository#15795
Assignees

Comments

@bobbypriam
Copy link
Contributor

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.

@ghost
Copy link

ghost commented Aug 6, 2018

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.

@bobbypriam
Copy link
Contributor Author

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

@ghost
Copy link

ghost commented Aug 13, 2018

Yes. However, AFAIR we never discussed the possibility of allowing dune exec hello.exe. Allowing it seems fine to me.

@rgrinberg
Copy link
Member

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.

@emillon emillon self-assigned this Jan 14, 2020
@voodoos
Copy link
Collaborator

voodoos commented Jan 14, 2020

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.

@ghost ghost closed this as completed in #3041 Jan 20, 2020
rgrinberg added a commit to rgrinberg/opam-repository that referenced this issue Feb 6, 2020
…lugin, dune-private-libs and dune-glob (2.2.0)

CHANGES:

- `dune test` is now a command alias for `dune runtest`. This is to make the CLI
  less idiosyncratic (ocaml/dune#3006, @shonfeder)

- Allow to set menhir flags in the `env` stanza using the `menhir_flags` field.
  (ocaml/dune#2960, fix ocaml/dune#2924, @bschommer)

- By default, do not show the full command line of commands executed
  by `dune` when `dune` is executed inside `dune`. This is to make
  integration tests more reproducible (ocaml/dune#3042, @diml)

- `dune subst` now works even without opam files (ocaml/dune#2955, fixes ocaml/dune#2910,
  @fangyi-zhou and @diml)

- Hint when trying to execute an executable defined in the current directory
  without using the `./` prefix (ocaml/dune#3041, fixes ocaml/dune#1094, @voodoos).

- Extend the list of modifiers that can be nested under
  `with-accepted-exit-codes` with `chdir`,  `setenv`, `ignore-<outputs>`,
  `with-stdin-from` and `with-<outputs>-to` (ocaml/dune#3027, fixes ocaml/dune#3014, @voodoos)

- It is now an error to have a preprocessing dependency on a ppx rewriter
  library that is not marked as `(kind ppx_rewriter)` (ocaml/dune#3039, @snowleopard).

- Fix permissions of files promoted to the source tree when using the
  shared cache. In particular, make them writable by the user (ocaml/dune#3043,
  fixes ocaml/dune#3026, @diml)

- Only detect internal OCaml tools with `.opt` extensions. Previously, this
  detection applied to other binaries as well (@kit-ty-kate, @rgrinberg, ocaml/dune#3051).

- Give the user a proper error message when they try to promote into a source
  directory that doesn't exist. (ocaml/dune#3073, fix ocaml/dune#3069, @rgrinberg)

- Correctly build vendored packages in `-p` mode. These packages were
  incorrectly filtered out before. (ocaml/dune#3705, @diml)

- Do not install vendored packages (ocaml/dune#3704, @diml)

- `make` now prints a message explaining the main targets available
  (ocaml/dune#3085, fix ocaml/dune#3078, @diml)

- Add a `byte_complete` executable mode to build programs as
  self-contained bytecode programs
  (ocaml/dune#3076, fixes ocaml/dune#1519, @diml)
mgree pushed a commit to mgree/opam-repository that referenced this issue Feb 19, 2020
…lugin, dune-private-libs and dune-glob (2.2.0)

CHANGES:

- `dune test` is now a command alias for `dune runtest`. This is to make the CLI
  less idiosyncratic (ocaml/dune#3006, @shonfeder)

- Allow to set menhir flags in the `env` stanza using the `menhir_flags` field.
  (ocaml/dune#2960, fix ocaml/dune#2924, @bschommer)

- By default, do not show the full command line of commands executed
  by `dune` when `dune` is executed inside `dune`. This is to make
  integration tests more reproducible (ocaml/dune#3042, @diml)

- `dune subst` now works even without opam files (ocaml/dune#2955, fixes ocaml/dune#2910,
  @fangyi-zhou and @diml)

- Hint when trying to execute an executable defined in the current directory
  without using the `./` prefix (ocaml/dune#3041, fixes ocaml/dune#1094, @voodoos).

- Extend the list of modifiers that can be nested under
  `with-accepted-exit-codes` with `chdir`,  `setenv`, `ignore-<outputs>`,
  `with-stdin-from` and `with-<outputs>-to` (ocaml/dune#3027, fixes ocaml/dune#3014, @voodoos)

- It is now an error to have a preprocessing dependency on a ppx rewriter
  library that is not marked as `(kind ppx_rewriter)` (ocaml/dune#3039, @snowleopard).

- Fix permissions of files promoted to the source tree when using the
  shared cache. In particular, make them writable by the user (ocaml/dune#3043,
  fixes ocaml/dune#3026, @diml)

- Only detect internal OCaml tools with `.opt` extensions. Previously, this
  detection applied to other binaries as well (@kit-ty-kate, @rgrinberg, ocaml/dune#3051).

- Give the user a proper error message when they try to promote into a source
  directory that doesn't exist. (ocaml/dune#3073, fix ocaml/dune#3069, @rgrinberg)

- Correctly build vendored packages in `-p` mode. These packages were
  incorrectly filtered out before. (ocaml/dune#3705, @diml)

- Do not install vendored packages (ocaml/dune#3704, @diml)

- `make` now prints a message explaining the main targets available
  (ocaml/dune#3085, fix ocaml/dune#3078, @diml)

- Add a `byte_complete` executable mode to build programs as
  self-contained bytecode programs
  (ocaml/dune#3076, fixes ocaml/dune#1519, @diml)
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment