Windows: removing directories can fail
Hi,
In some cases dune-release (on Windows) creates files that it does not manage to remove:
$ dune-release distrib --skip-test
[-] Building source archive
dune-release.exe: [WARNING] The repo is dirty. The distribution archive may
be inconsistent. Uncommitted changes to files
(including dune-project) will be ignored.
[+] Wrote archive _build\ocamlformat-0.17.0.tbz
[-] Linting distrib in _build\ocamlformat-0.17.0
[ OK ] File README is present.
[ OK ] File LICENSE is present.
[ OK ] File CHANGES is present.
[ OK ] File opam is present.
[ OK ] lint opam file ocamlformat.opam.
[ OK ] opam field description is present
[ OK ] opam fields homepage and dev-repo can be parsed by dune-release
[ OK ] Skipping doc field linting, no doc field found
[ OK ] lint _build\ocamlformat-0.17.0 success
[-] Building package in _build\ocamlformat-0.17.0
[ OK ] package builds
dune-release.exe: [ERROR] delete directory _build\ocamlformat-0.17.0: _build\ocamlformat-0.17.0\_build\.aliases\default\install-0 00000000000000000000000000000000: The directory name is invalid.
Ultimately this looks like a bug in bos but we should be able to debug it in the context of dune-release.
I narrowed this down to opendir returning that error. It's not clear how that file is created. Copying it with the same attributes creates a file that can be succesfully removed with Bos.OS.Dir.delete. Renaming the file also preserves deletability. This looks like something that's inherent to the file. A process might still have it open, but no dune process seems to be running. And dune clean and unlink file can remove this file.
I had a look at it and couldn't find anything, does using the verbose mode -vv give more information that can help?