ocaml / dune

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

Race condition building project with package management #10903

Open gridbugs opened 1 month ago

gridbugs commented 1 month ago

Sometimes when building a project with package management I see this error:

    Building ocaml-base-compiler.5.2.0  
    Building ocaml-config.3      
    Building base-unix.base      
    Building ocaml.5.2.0         
    Building seq.base              
    Building ocamlfind.1.9.6+dune  
Error:                             
_build/.sandbox/bed9cbdb5ceececaf0c3aaddc1db1624/_private/default/.dev-tool/odoc/ocamlfind/source/0001-Harden-test-for-OCaml-5.patch:
No such file or directory
-> required by _build/_private/default/.dev-tool/odoc/ocamlfind/target/cookie
-> required by - package topkg
-> required by - package astring
-> required by - package odoc
    Building ocamlbuild.0.15.0+dune

I've seen this on a range of projects, but so far I've only seen it on this specific patch from ocamlfind's package. I don't have a reliable reproduction case yet. It happens very infrequently, and the project always builds as expected when I rerun the command.

moyodiallo commented 1 month ago

This is not linked to race condition. I've tried to print the file path, running dune fmt. I assume you're testing with #10647. It seems the problem is coming from there.

It prints: extra_files: _build/_private/default/.pkg/ocamlfind/source/0001-Harden-test-for-OCaml-5.patch

instead of .dev-tool it is copying inside .pkg.

moyodiallo commented 1 month ago

This is not linked to race condition. I've tried to print the file path, running dune fmt. I assume you're testing with #10647. It seems the problem is coming from there.

It prints: extra_files: _build/_private/default/.pkg/ocamlfind/source/0001-Harden-test-for-OCaml-5.patch

instead of .dev-tool it is copying inside .pkg.

My bad, this is not true.

moyodiallo commented 1 month ago

I noticed every time you do an initial dune fmt the error appears and after that any time you try to rebuild without cleaning(removing the dev-tool locks), it's works.

I think there's a rule that coming before another one and it's not supposed to do that.