Description
Expected Behavior
Builds pass without issues
Actual Behavior
I see in various builds a lot errors of the form:
Error: failed to delete sandbox in
_build/.sandbox/027fb85dd9ad3f86a15ca2259967f6e0
Reason:
rmdir(_build/.sandbox/027fb85dd9ad3f86a15ca2259967f6e0\default\.ppx\f7b2eee21a8c0e54401ad28ca0581bfe): Directory not empty
this does not happen with all opam packages, but it happens very reliably with some, e.g. sel
and coq-elpi
. Interestingly they are both from the same author (@gares FYI). But I can't say there anything particularly strange about these packages. In all cases the remaining file in the sandbox is ppx.exe
.
Reproduction
Build via opam e.g. the package sel
on Windows when a virus scanner is present (I use GData, but it shouldn't matter much). It should fail > 80% with such an error.
The issue is that on Windows, unlike Linux and MacOS, files are identified by name and not by inode. On Linux a file name is just a link to an inode. If a a file is deleted, it doesn't delete the file, it just removes the inode link. If the inode link is 0, the file itself is deleted. An open file also has an inode link, so on Linux one can delete open files. On Windows this does not work. I file cannot be deleted while it is open.
The issue is that virus scanners tend to inspec all new .exe files, so they have this file opened, which means you cannot delete it. This is the reason why removing the sandbox fails on Windows if a virus scanner is present.
Specifications
- Version of
dune
(output ofdune --version
): 3.16.1 - Version of
ocaml
(output ofocamlc --version
): 4.14.2 - Operating system (distribution and version): Windows 11, cygwin, MinGW cross (Coq Platform)
Additional information
Possible remedies are:
- retry deleting files if deleting a file fails - usually a virus scanner doesn't keep files locked for more than a few seconds
- by default disable sandboxing on Windows
- for cygwin MinGW cross dune it should be documented that the location of the config file is not cygwin home, but Windows home (somehow obvious but not to every body).