ocaml / dune

A composable build system for OCaml.
https://dune.build/
MIT License
1.64k stars 409 forks source link

Dune crashes when editing a file in exec watch mode #11010

Open LAC-Tech opened 1 month ago

LAC-Tech commented 1 month ago

Expected Behavior

Dune not to crash when editing data.ml

Actual Behavior

Dune crashes when data.ml is edited, even if you just save the file without changing anything, with this output:

Error: _build/default/.hello.eobjs/dune__exe__Hello.impl.d: No such file or
directory
-> required by _build/default/.hello.eobjs/dune__exe__Hello.impl.all-deps
-> required by _build/default/hello.exe
Had 1 error, waiting for filesystem changes...      

Reproduction

clone https://github.com/LAC-Tech/dunebug run

dune exec -w ./hello.exe

Save file data.ml in your editor. (saving hello.ml works fine). You may sometimes have to save 2 or 3 times to get it to crash.

Specifications

dune 3.16.0 The OCaml toplevel, version 5.2.0 Arch Linux, kernel 6.10.6, x86_64

maiste commented 1 month ago

This might be related to #10959.

maiste commented 1 month ago

@LAC-Tech could you try again and tell me if it is working with the latest version of dune? It seems to have been fixed with #10960. I can't reproduce with your example again using main version of dune.

LAC-Tech commented 3 weeks ago

Hi, excuse the late reply and basic question - but what's the best way to get this main dune version? build myself, install with opam flag? Just point me in the right direction.

maiste commented 3 weeks ago

You can either build it yourself or use the binary version from https://preview.dune.build (nightly version of dune built from the main branch).

LAC-Tech commented 3 weeks ago

Thanks. Exact same issue I'm afraid.

$ ~/.dune/bin/dune --version
"Dune Developer Preview: build 2024-11-02T02:13:00Z, git revision
c2e0160fd0b593c63536c7081238da1da5140720"

Then running with: ~/.dune/bin/dune exec -w ./hello.exe, and saving data.ml (which seems to be what's causing the race condition), I get the same error message.

Tried with a plain neovim, default config no plugins incase an LSP was causing an issue. But no luck.

Is there any information I can provide that might help?

maiste commented 3 weeks ago

Thanks for trying! I was betting on the fact that the mentioned PR introduced delays in computation that could possibly solve the issue. Apparently not.

You already provided a reproduction case so we don't need extra information.