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

diff? error: Rule failed to generate the following targets #2990

Closed
anton-trunov opened this issue Dec 31, 2019 · 4 comments · Fixed by ocaml/opam-repository#16585
Closed
Labels

Comments

@anton-trunov
Copy link

Please consider the following self-contained example in the form of a dune file:

(executable
 (name print)
 (modules print))

(rule
 (with-stdout-to print.ml
  (echo "let () = print_endline \"MESSAGE\"")))

(rule
 (alias runtest)
 (action
  (progn
   (with-stdout-to output.expected (echo "MESSAGE\n"))
   (with-stdout-to output.actual (run ./print.exe))
   (diff? output.expected output.actual))))

When I run dune runtest it generates the following error message which I find confusing:

$ dune runtest
File "dune", line 9, characters 0-195:
 9 | (rule
10 |  (alias runtest)
11 |  (action
12 |    (progn
13 |     (with-stdout-to output.expected (echo "MESSAGE\n"))
14 |     (with-stdout-to output.actual (run ./print.exe))
15 |     (diff? output.expected output.actual))))
Error: Rule failed to generate the following targets:
- output.actual

According to the manual,

(diff? ) is similar to (diff ) except that should be produced by a part of the same action rather than be a dependency, is optional and will be consumed by diff?.

In this case (please correct me if I'm wrong) is produced as a part of the same action, so I would expect no error. Changing (diff? ... to (diff ... works as expected. Perhaps it's a documentation issue?

@ghost
Copy link

ghost commented Jan 6, 2020

The documentation looks correct; it states that diff? will consume output.actual. That's why it doesn't appear as a target. However, the problem is that dune targets inference doesn't detect this case. i.e. it should know that diff? will delete output.actual and so should consider output.actual as a target.

@ghost ghost added the bug label Jan 6, 2020
@ghost
Copy link

ghost commented Jan 6, 2020

If you'd like to take a stab at fixing this issue, the code to change is in the Infer sub-module in src/dune/action_unexpanded.ml. In the | Diff branch of the infer function, if optional is true we need to remove file2 from the set of targets.

Otherwise, one of us will look at this at some point.

greedy pushed a commit to greedy/dune that referenced this issue May 5, 2020
The second argument of a 'diff?' action is removed from the set of
targets as the action consumes (i.e. deletes) the file.
greedy added a commit to greedy/dune that referenced this issue May 5, 2020
The second argument of a 'diff?' action is removed from the set of
targets as the action consumes (i.e. deletes) the file.
greedy added a commit to greedy/dune that referenced this issue May 5, 2020
The second argument of a 'diff?' action is removed from the set of
targets as the action consumes (i.e. deletes) the file.

Signed-off-by: Geoffrey Reedy <geoff@programmer-monk.net>
greedy added a commit to greedy/dune that referenced this issue May 5, 2020
The second argument of a 'diff?' action is removed from the set of
targets as the action consumes (i.e. deletes) the file.

Signed-off-by: Geoffrey Reedy <geoff@programmer-monk.net>
@greedy
Copy link
Contributor

greedy commented May 5, 2020

I was bitten by this bug too so I took a stab at a fix.

rgrinberg pushed a commit to greedy/dune that referenced this issue May 6, 2020
The second argument of a 'diff?' action is removed from the set of
targets as the action consumes (i.e. deletes) the file.

Signed-off-by: Geoffrey Reedy <geoff@programmer-monk.net>
rgrinberg added a commit that referenced this issue May 6, 2020
ghost pushed a commit that referenced this issue May 6, 2020
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
@ghost
Copy link

ghost commented May 6, 2020

This has been fixed.

@ghost ghost closed this as completed May 6, 2020
rgrinberg added a commit to rgrinberg/opam-repository that referenced this issue Jun 6, 2020
…lugin, dune-private-libs and dune-glob (2.6.0)

CHANGES:

- Fix a bug where valid lib names in `dune init exec --libs=lib1,lib2`
  results in an error. (ocaml/dune#3444, fix ocaml/dune#3443, @bikallem)

- Add and `enabled_ if` field to the `install` stanza. Enforce the same variable
  restrictions for `enabled_if` fields in the `executable` and `install` stanzas
  than in the `library` stanza. When using dune lang < 2.6, the usage of
  forbidden variables in executables stanzas with only trigger a warning to
  maintain compatibility. (ocaml/dune#3408 and ocaml/dune#3496, fixes ocaml/dune#3354, @voodoos)

- Insert a constraint one the version of dune when the user explicitly
  specify the dependency on dune in the `dune-project` file (ocaml/dune#3434 ,
  fixes ocaml/dune#3427, @diml)

- Generate correct META files for sub-libraries (of the form `lib.foo`) that
  contain .js runtime files. (ocaml/dune#3445, @hhugo)

- Add a `(no-infer ...)` action that prevents inference of targets and
  dependencies in actions. (ocaml/dune#3456, fixes ocaml/dune#2006, @roddyyaga)

- Correctly infer targets for the `diff?` action. (ocaml/dune#3457, fixes ocaml/dune#2990, @greedy)

- Fix `$ dune print-rules` crashing (ocaml/dune#3459, fixes ocaml/dune#3440, @rgrinberg)

- Simplify js_of_ocaml rules using js_of_ocaml.3.6 (ocaml/dune#3375, @hhugo)

- Add a new `ocaml-merlin` subcommand that can be used by Merlin to get
  configuration directly from dune instead of using `.merlin` files. (ocaml/dune#3395,
  @voodoos)

- Remove experimental variants feature and make default implementations part of
  the language (ocaml/dune#3491, fixes ocaml/dune#3483, @rgrinberg)
rgrinberg added a commit to rgrinberg/opam-repository that referenced this issue Jun 7, 2020
…lugin, dune-private-libs and dune-glob (2.6.0)

CHANGES:

- Fix a bug where valid lib names in `dune init exec --libs=lib1,lib2`
  results in an error. (ocaml/dune#3444, fix ocaml/dune#3443, @bikallem)

- Add and `enabled_ if` field to the `install` stanza. Enforce the same variable
  restrictions for `enabled_if` fields in the `executable` and `install` stanzas
  than in the `library` stanza. When using dune lang < 2.6, the usage of
  forbidden variables in executables stanzas with only trigger a warning to
  maintain compatibility. (ocaml/dune#3408 and ocaml/dune#3496, fixes ocaml/dune#3354, @voodoos)

- Insert a constraint one the version of dune when the user explicitly
  specify the dependency on dune in the `dune-project` file (ocaml/dune#3434 ,
  fixes ocaml/dune#3427, @diml)

- Generate correct META files for sub-libraries (of the form `lib.foo`) that
  contain .js runtime files. (ocaml/dune#3445, @hhugo)

- Add a `(no-infer ...)` action that prevents inference of targets and
  dependencies in actions. (ocaml/dune#3456, fixes ocaml/dune#2006, @roddyyaga)

- Correctly infer targets for the `diff?` action. (ocaml/dune#3457, fixes ocaml/dune#2990, @greedy)

- Fix `$ dune print-rules` crashing (ocaml/dune#3459, fixes ocaml/dune#3440, @rgrinberg)

- Simplify js_of_ocaml rules using js_of_ocaml.3.6 (ocaml/dune#3375, @hhugo)

- Add a new `ocaml-merlin` subcommand that can be used by Merlin to get
  configuration directly from dune instead of using `.merlin` files. (ocaml/dune#3395,
  @voodoos)

- Remove experimental variants feature and make default implementations part of
  the language (ocaml/dune#3491, fixes ocaml/dune#3483, @rgrinberg)
rgrinberg added a commit to rgrinberg/opam-repository that referenced this issue Jun 7, 2020
…lugin, dune-private-libs and dune-glob (2.6.0)

CHANGES:

- Fix a bug where valid lib names in `dune init exec --libs=lib1,lib2`
  results in an error. (ocaml/dune#3444, fix ocaml/dune#3443, @bikallem)

- Add and `enabled_ if` field to the `install` stanza. Enforce the same variable
  restrictions for `enabled_if` fields in the `executable` and `install` stanzas
  than in the `library` stanza. When using dune lang < 2.6, the usage of
  forbidden variables in executables stanzas with only trigger a warning to
  maintain compatibility. (ocaml/dune#3408 and ocaml/dune#3496, fixes ocaml/dune#3354, @voodoos)

- Insert a constraint one the version of dune when the user explicitly
  specify the dependency on dune in the `dune-project` file (ocaml/dune#3434 ,
  fixes ocaml/dune#3427, @diml)

- Generate correct META files for sub-libraries (of the form `lib.foo`) that
  contain .js runtime files. (ocaml/dune#3445, @hhugo)

- Add a `(no-infer ...)` action that prevents inference of targets and
  dependencies in actions. (ocaml/dune#3456, fixes ocaml/dune#2006, @roddyyaga)

- Correctly infer targets for the `diff?` action. (ocaml/dune#3457, fixes ocaml/dune#2990, @greedy)

- Fix `$ dune print-rules` crashing (ocaml/dune#3459, fixes ocaml/dune#3440, @rgrinberg)

- Simplify js_of_ocaml rules using js_of_ocaml.3.6 (ocaml/dune#3375, @hhugo)

- Add a new `ocaml-merlin` subcommand that can be used by Merlin to get
  configuration directly from dune instead of using `.merlin` files. (ocaml/dune#3395,
  @voodoos)

- Remove experimental variants feature and make default implementations part of
  the language (ocaml/dune#3491, fixes ocaml/dune#3483, @rgrinberg)
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants