Dune cache does not restore empty directories. On top of not being very nice, this has really bad consequences with caching because dune's rule digest algorithm does take empty directories in account, so restoring a rule from cache will invalidate all dependent rules as the sources hash will have changed.
This is especially painful with the dune pkg feature, as the Ocaml 5.2.0 tarball has an empty flexdll directory at the root, so pulling it from the cache will rebuild absolutely everything.
I suppose the correct behavior is to properly restore empty directories from cache. If not, they probably shouldn't count towards rule digests.
Issue
Dune cache does not restore empty directories. On top of not being very nice, this has really bad consequences with caching because dune's rule digest algorithm does take empty directories in account, so restoring a rule from cache will invalidate all dependent rules as the sources hash will have changed.
This is especially painful with the dune pkg feature, as the Ocaml 5.2.0 tarball has an empty flexdll directory at the root, so pulling it from the cache will rebuild absolutely everything.
I suppose the correct behavior is to properly restore empty directories from cache. If not, they probably shouldn't count towards rule digests.
Reproduction