cargo clean failure with dangling readonly dir-symlinks on windows #11872
Labels
A-filesystem
Area: issues with filesystems
C-bug
Category: bug
Command-clean
O-windows
OS: Windows
S-triage
Status: This issue is waiting on initial triage.
Problem
Rustup creates symlinks within target/ in its test suite.
Here is an example:
and in cmd:
Inspecting with explorer shows that the link is a readonly dir link.
This is a dangling link (likely because cargo clean deleted the target first).
cargo clean fails:
rm
from within bash deletes the file successfully, which permits cargo clean to proceed.I haven't tested yet, but I suspect the
remove_dir_all
function in the stdlib would handle this correctly. I have tested theremove_dir_all
crate's equivalent API, and it does handle this correctly.The code in _remove_file calls a helper that doesn't use
symlink_metadata
, rathermetadata
, which will fail on dangling symlinks.Separately I also note that the entire routine is based on path based calls rather than _at style calls, which will incur higher traversal costs in-kernel, and is serial, even though directory removal is embarrassingly parallel : if you're interested I could look at what changes would be needed to the
remove_dir_all
crate to support the UI cargo wants, to permit switching to that. Parallel deletion of installed toolchains had a measurable speed improvement for rustup, both in our test suite and for users.Steps
No response
Possible Solution(s)
No response
Notes
No response
Version
The text was updated successfully, but these errors were encountered: