program output from `exec -w` and rule actions interspersed with repeated dune status output
Expected Behavior
When running an action associated with a rule, or dune execing an executable (both with watch-mode enabled, -w), no (apparent) console printing aside from the action/program being invoked should occur.
Actual Behavior
After upgrading to dune 3.7.1 (from 3.4.1), it now repeatedly prints a penultimate status update, e.g. Done: 99% (1202/1203, 1 left) before every line printed to stdout/err by a long-running process invoked via a rule's action. It appears to only watch-mode invocations, e.g. dune build @rundev -w --no-buffer.
Previously, it only printed that kind of progress message once, right before the action ran.
The same sort of issue appears when running a program via dune exec -w ..., though in that case, the repeated unwanted print is Success, waiting for filesystem changes....
Assuming dune isn't actually writing the same message over and over, I suspect the repeated messages are an artifact of how dune is writing to the connected terminal?
Reproduction
Add a rule to a dune file, with a run action pointing to an executable that emits e.g. log messages periodically, e.g.
(rule
(alias rundev)
(action
(run %{bin:....})))
Specifications
- Version of
dune(output ofdune --version): 3.7.1 - Version of
ocaml(output ofocamlc --version): 5.0.0 - Operating system (distribution and version): Ubuntu 22.04.2, Linux 5.19
Assuming dune isn't actually writing the same message over and over, I suspect the repeated messages are an artifact of how dune is writing to the connected terminal?
I've been able to work around this by piping dune's output through cat, e.g.:
dune build @rundev -w --no-buffer 2>&1 | cat
contains no spurious build status messages. I think that confirms that this is a terminal-handling issue, rather than any actually-repetitive console printing on dune's part.
We recently fixed a clearing issue with dune exec. Could you test this on main to see if it is still an issue for you?
- Clone this repo
- cd to it
- run
make _boot/dune.exeto make the bootstrapped version of dune - run
./dune.exe build @installto build the dune binary - run
_build/install/default/bin/dunein the project you want to test, obviously relativising the path.
Yes, this is improved on main, though I wouldn't say it's entirely fixed:
- the constant spurious messages are now gone
- when running a rule's action, the final status message (e.g.
Done: 99% (1208/1209, 1 left) (jobs: 1)) is still left in the terminal. This is basically the prior behaviour (from prior to my upgrading to OCaml 5 / dune 3.7.x). - when using
dune exec -w ...,Success, waiting for filesystem changes...is still printed/shown twice: once right before the start of the program's output, and then again after the initial flurry of startup messages that my app happens to print out. This is then repeated after any filesystem change and the subsequent build completes.
tl;dr, not bad / tolerable. If there are any further patches related to this, I'm happy to test main again.