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

Bad interaction between '(mode promote-until-clean)' and tests ran with '-p <pkg>' #4401

Closed
Gbury opened this issue Mar 25, 2021 · 1 comment · Fixed by #5956 or ocaml/opam-repository#22317
Assignees
Labels
Milestone

Comments

@Gbury
Copy link
Contributor

Gbury commented Mar 25, 2021

Expected Behavior

When using a file (let's say test) that is "promoted until clean" as a dep for a test defined for a specific package foo, dune build @runtest -p foo should succeed.

Actual Behavior

dune build @runtest -p foo fails with Error: No rule found for test.
The conjunction of (mode promote-until-clean) and -p <pkg> seems to make dune "forget" about how to build some targets. I don't know if that is expected and if so, what is the correct way to do things.

Reproduction

See https://gist.github.com/Gbury/598f0b6f751767e8a66fe9c508704976

dune file:

(rule
  (target test)
  (mode promote-until-clean) ; without this, everything runs fine 
                             ; but with it, dune complains about "No rule found for test"
  (action (with-stdout-to %{target} (run echo foobar)))
)

(rule
  (alias runtest)
  (package foo)
  (deps (:test test))
  (action (diff %{test} reference))
)
  1. dune build @runtest succeeds as can be expected
  2. dune build @runtest -p foo fails with "Error: No rule found for test" (make sure to dune clean between attempts, particularly after a successful run)
  3. If the (mode promote-until-clean) is commented out, dune build @runtest -p foo succeeds

Specifications

  • Version of dune (output of dune --version): 2.8.4
  • Version of ocaml (output of ocamlc --version): 4.11.1
  • Operating system (distribution and version): archlinux 5.11.9-arch1-1

Additional information

In practice, this happens to me in the dolmen project (see e.g. this dune file), where a rule is defined to generate an updated version of menhir's error message file (which is promoted-until-clean, since it is meant to be used as a reference when updating the error messages after changing the grammar), and another rule is defined to use that file to check that all error states have an error message written.

@ghost
Copy link

ghost commented Mar 26, 2021

I see the problem. -p implies --release, which implies --ignore-promoted-rules. This was intended for rules with (mode promote), which is intended for files that are both generated and committed. Dune ignore such rules during release builds so that it takes the file in the source tree directly rather than re-generating it. This speeds up release builds and can also be used to cut down dependencies.

However, it seems that currently --ignore-promoted-rules also ignores rules with (mode promote-until-clean), which is clearly wrong, given that such temporarily promoted files are clearly not meant to be committed in the repository.

I'm marking this as a bug and scheduling it for Dune 3.0. Do you want to give a shot a writing a fix for it? Happy to give you some pointers if yes.

@ghost ghost added the bug label Mar 26, 2021
@ghost ghost added this to the 3.0 milestone Mar 26, 2021
@ghost ghost removed this from the 3.0 milestone Oct 20, 2021
@emillon emillon self-assigned this Jul 12, 2022
emillon added a commit to emillon/dune that referenced this issue Jul 12, 2022
Signed-off-by: Etienne Millon <[email protected]>
emillon added a commit to emillon/dune that referenced this issue Jul 12, 2022
emillon added a commit to emillon/dune that referenced this issue Jul 18, 2022
Signed-off-by: Etienne Millon <[email protected]>
emillon added a commit that referenced this issue Jul 18, 2022
Signed-off-by: Etienne Millon <[email protected]>
emillon added a commit to emillon/dune that referenced this issue Jul 19, 2022
emillon added a commit to emillon/dune that referenced this issue Aug 1, 2022
emillon added a commit to emillon/dune that referenced this issue Aug 1, 2022
emillon added a commit that referenced this issue Aug 1, 2022
* Keep rules marked promote until-clean with -p

Closes #4401

Signed-off-by: Etienne Millon <[email protected]>

* Update test/blackbox-tests/test-cases/github4401.t

Co-authored-by: Christine Rose <[email protected]>
Signed-off-by: Etienne Millon <[email protected]>

Co-authored-by: Christine Rose <[email protected]>
emillon added a commit to emillon/opam-repository that referenced this issue Oct 11, 2022
…ne-site, dune-rpc, dune-rpc-lwt, dune-private-libs, dune-glob, dune-configurator, dune-build-info, dune-action-plugin and chrome-trace (3.5.0~alpha1)

CHANGES:

- Sandbox running cinaps actions starting from cinaps 1.1 (ocaml/dune#6176, @rgrinberg)

- Add a `runtime_deps` field in the `cinaps` stanza to specify runtime
  dependencies for running the cinaps preprocessing action (ocaml/dune#6175, @rgrinberg)

- Shadow alias module `Foo__` when building a library `Foo` (ocaml/dune#6126, @rgrinberg)

- Extend dune describe to include the root path of the workspace and the
  relative path to the build directory. (ocaml/dune#6136, @reubenrowe)

- Allow dune describe workspace to accept directories as arguments.
  The provided directories restrict the worskpace description to those
  directories. (ocaml/dune#6107, fixes ocaml/dune#3893, @esope)

- Add a terminal persistence mode that attempts to clear the terminal history.
  It is enabled by setting terminal persistence to
  `clear-on-rebuild-and-flush-history` (ocaml/dune#6065, @rgrinberg)

- Disallow generating targets in sub direcories in inferred rules. The check to
  forbid this was accidentally done only for manually specified targets (ocaml/dune#6031,
  @rgrinberg)

- Do not ignore rules marked `(promote (until-clean))` when
  `--ignore-promoted-rules` (or `-p`) is passed. (ocaml/dune#6010, fixes ocaml/dune#4401, @emillon)

- Dune no longer considers .aux files as targets during Coq compilation. This
  means that .aux files are no longer cached. (ocaml/dune#6024, fixes ocaml/dune#6004, @Alizter)

- Cinaps actions are now sandboxed by default (ocaml/dune#6062, @rgrinberg)

- Allow rules producing directory targets to be not sandboxed (ocaml/dune#6056,
  @rgrinberg)

- Introduce a `dirs` field in the `install` stanza to install entire
  directories (ocaml/dune#5097, fixes ocaml/dune#5059, @rgrinberg)

- Menhir rules are now sandboxed by default (ocaml/dune#6076, @rgrinberg)

- Allow rules producing directory targets to create symlinks (ocaml/dune#6077, fixes
  ocaml/dune#5945, @rgrinberg)

- Inline tests are now sandboxed by default (ocaml/dune#6079, @rgrinberg)

- Fix build-info version when used with flambda (ocaml/dune#6089, fixes ocaml/dune#6075, @jberdine)

- Add an `(include <file>)` term to the `include_dirs` field for adding
  directories to the include paths sourced from a file. (ocaml/dune#6058, fixes ocaml/dune#3993,
  @gridbugs)

- Support `(extra_objects ...)` field in `(executable ...)` and `(library
  ...)` stanzas (ocaml/dune#6084, fixes ocaml/dune#4129, @gridbugs)

- Fix compilation of Dune under esy on Windows (ocaml/dune#6109, fixes ocaml/dune#6098, @nojb)

- Improve error message when parsing several licenses in `(license)` (ocaml/dune#6114,
  fixes ocaml/dune#6103, @emillon)

- odoc rules now about `ODOC_SYNTAX` and will rerun accordingly (ocaml/dune#6010, fixes
  ocaml/dune#1117, @emillon)

- dune install: copy files in an atomic way (ocaml/dune#6150, @emillon)

- Add `%{coq:...}` macro for accessing data about the configuration about Coq.
  For instance `%{coq:version}` (ocaml/dune#6049, @Alizter)

- update vendored copy of cmdliner to 1.1.1. This improves the built-in
  documentation for command groups such as `dune ocaml`. (ocaml/dune#6038, @emillon,
  ocaml/dune#6169, @shonfeder)

- The test suite for Coq now requires Coq >= 8.16 due to changes in the
  plugin loading mechanism upstream (which now uses findlib).

- Starting with Coq build language 0.6, theories can be built without importing
  Coq's standard library by including `(stdlib no)`.
  (ocaml/dune#6165 ocaml/dune#6164, fixes ocaml/dune#6163, @ejgallego @Alizter @LasseBlaauwbroek)

- on macOS, sign executables produced by artifact substitution (ocaml/dune#6137, fixes
  ocaml/dune#5650, @emillon)

- Added an (aliases ...) field to the (rules ...) stanza which allows the
  specification of multiple aliases per rule (ocaml/dune#6194, @Alizter)
emillon added a commit to emillon/opam-repository that referenced this issue Oct 19, 2022
…ne-site, dune-rpc, dune-rpc-lwt, dune-private-libs, dune-glob, dune-configurator, dune-build-info, dune-action-plugin and chrome-trace (3.5.0)

CHANGES:

- macOS: Handle unknown fsevents without crashing (ocaml/dune#6217, @rgrinberg)

- Enable file watching on MacOS SDK < 10.13. (ocaml/dune#6218, @rgrinberg)

- Sandbox running cinaps actions starting from cinaps 1.1 (ocaml/dune#6176, @rgrinberg)

- Add a `runtime_deps` field in the `cinaps` stanza to specify runtime
  dependencies for running the cinaps preprocessing action (ocaml/dune#6175, @rgrinberg)

- Shadow alias module `Foo__` when building a library `Foo` (ocaml/dune#6126, @rgrinberg)

- Extend dune describe to include the root path of the workspace and the
  relative path to the build directory. (ocaml/dune#6136, @reubenrowe)

- Allow dune describe workspace to accept directories as arguments.
  The provided directories restrict the worskpace description to those
  directories. (ocaml/dune#6107, fixes ocaml/dune#3893, @esope)

- Add a terminal persistence mode that attempts to clear the terminal history.
  It is enabled by setting terminal persistence to
  `clear-on-rebuild-and-flush-history` (ocaml/dune#6065, @rgrinberg)

- Disallow generating targets in sub direcories in inferred rules. The check to
  forbid this was accidentally done only for manually specified targets (ocaml/dune#6031,
  @rgrinberg)

- Do not ignore rules marked `(promote (until-clean))` when
  `--ignore-promoted-rules` (or `-p`) is passed. (ocaml/dune#6010, fixes ocaml/dune#4401, @emillon)

- Dune no longer considers .aux files as targets during Coq compilation. This
  means that .aux files are no longer cached. (ocaml/dune#6024, fixes ocaml/dune#6004, @Alizter)

- Cinaps actions are now sandboxed by default (ocaml/dune#6062, @rgrinberg)

- Allow rules producing directory targets to be not sandboxed (ocaml/dune#6056,
  @rgrinberg)

- Introduce a `dirs` field in the `install` stanza to install entire
  directories (ocaml/dune#5097, fixes ocaml/dune#5059, @rgrinberg)

- Menhir rules are now sandboxed by default (ocaml/dune#6076, @rgrinberg)

- Allow rules producing directory targets to create symlinks (ocaml/dune#6077, fixes
  ocaml/dune#5945, @rgrinberg)

- Inline tests are now sandboxed by default (ocaml/dune#6079, @rgrinberg)

- Fix build-info version when used with flambda (ocaml/dune#6089, fixes ocaml/dune#6075, @jberdine)

- Add an `(include <file>)` term to the `include_dirs` field for adding
  directories to the include paths sourced from a file. (ocaml/dune#6058, fixes ocaml/dune#3993,
  @gridbugs)

- Support `(extra_objects ...)` field in `(executable ...)` and `(library
  ...)` stanzas (ocaml/dune#6084, fixes ocaml/dune#4129, @gridbugs)

- Fix compilation of Dune under esy on Windows (ocaml/dune#6109, fixes ocaml/dune#6098, @nojb)

- Improve error message when parsing several licenses in `(license)` (ocaml/dune#6114,
  fixes ocaml/dune#6103, @emillon)

- odoc rules now about `ODOC_SYNTAX` and will rerun accordingly (ocaml/dune#6010, fixes
  ocaml/dune#1117, @emillon)

- dune install: copy files in an atomic way (ocaml/dune#6150, @emillon)

- Add `%{coq:...}` macro for accessing data about the configuration about Coq.
  For instance `%{coq:version}` (ocaml/dune#6049, @Alizter)

- update vendored copy of cmdliner to 1.1.1. This improves the built-in
  documentation for command groups such as `dune ocaml`. (ocaml/dune#6038, @emillon,
  ocaml/dune#6169, @shonfeder)

- The test suite for Coq now requires Coq >= 8.16 due to changes in the
  plugin loading mechanism upstream (which now uses `Findlib`).

- Starting with Coq build language 0.6, theories can be built without importing
  Coq's standard library by including `(stdlib no)`.
  (ocaml/dune#6165 ocaml/dune#6164, fixes ocaml/dune#6163, @ejgallego @Alizter @LasseBlaauwbroek)

- on macOS, sign executables produced by artifact substitution (ocaml/dune#6137, ocaml/dune#6231,
  fixes ocaml/dune#5650, fixes ocaml/dune#6226, @emillon)

- Added an (aliases ...) field to the (rules ...) stanza which allows the
  specification of multiple aliases per rule (ocaml/dune#6194, @Alizter)

- The `(coq.theory ...)` stanza will now ensure that for each declared `(plugin
 ...)`, the `META` file for it is built before calling `coqdep`. This enables
 the use of the new `Findlib`-based loading method in Coq 8.16; however as of
 Coq 8.16.0, Coq itself has some bugs preventing this to work yet. (ocaml/dune#6167 ,
 workarounds ocaml/dune#5767, @ejgallego)

- Allow include statement in install stanza (ocaml/dune#6139, fixes ocaml/dune#256, @gridbugs)

- Handle CSI n K code in ANSI escape codes from commands. (ocaml/dune#6214, fixes ocaml/dune#5528,
  @emillon)

- Add a new experimental feature `mode_specific_stubs` that allows the
  specification of different flags and sources for foreign stubs depending on
  the build mode (ocaml/dune#5649, @voodoos)
@rgrinberg rgrinberg added this to the 3.5.0 milestone Aug 25, 2023
rgrinberg added a commit that referenced this issue Aug 26, 2023
Bug #4401 was `(promote until-clean)` rules being incorrectly ignored by
`--ignore-promoted-rules`. PR #5956 fixed it but only made the fix
available to newer projects.

This means that projects must update their dune versions before users
can actually build this project without being affected by this bug.
Since this bug fix doesn't have much the potential to break anything, we
make the fix available to all versions.

Signed-off-by: Rudi Grinberg <[email protected]>

<!-- ps-id: 82b639c6-a417-4ae8-8cd2-fae02849ea83 -->
rgrinberg added a commit that referenced this issue Aug 26, 2023
Bug #4401 was `(promote until-clean)` rules being incorrectly ignored by
`--ignore-promoted-rules`. PR #5956 fixed it but only made the fix
available to newer projects.

This means that projects must update their dune versions before users
can actually build this project without being affected by this bug.
Since this bug fix doesn't have much the potential to break anything, we
make the fix available to all versions.

Signed-off-by: Rudi Grinberg <[email protected]>

<!-- ps-id: 82b639c6-a417-4ae8-8cd2-fae02849ea83 -->
rgrinberg added a commit that referenced this issue Aug 26, 2023
Bug #4401 was `(promote until-clean)` rules being incorrectly ignored by
`--ignore-promoted-rules`. PR #5956 fixed it but only made the fix
available to newer projects.

This means that projects must update their dune versions before users
can actually build this project without being affected by this bug.
Since this bug fix doesn't have much the potential to break anything, we
make the fix available to all versions.

Signed-off-by: Rudi Grinberg <[email protected]>

<!-- ps-id: 82b639c6-a417-4ae8-8cd2-fae02849ea83 -->
rgrinberg added a commit to rgrinberg/sedlex that referenced this issue Aug 26, 2023
`(promote (until-clean))` is ignored when `--ignore-promoted-rules` is
passed in later versions of dune.

See
ocaml/dune#4401
ocaml/dune#5956

Signed-off-by: Rudi Grinberg <[email protected]>
toots pushed a commit to ocaml-community/sedlex that referenced this issue Aug 26, 2023
`(promote (until-clean))` is ignored when `--ignore-promoted-rules` is
passed in later versions of dune.

See
ocaml/dune#4401
ocaml/dune#5956

Signed-off-by: Rudi Grinberg <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment