You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dir
Volume in drive C has no label.
Volume Serial Number is DE41-BA52
Directory of C:\Users\username\Documents\src\rustup.rs\target\tests\running-test-5D1PNf\rustupiIcEHF\toolchains
27/02/2023 11:44 AM <DIR> .
20/03/2023 11:22 PM <DIR> ..
27/02/2023 11:44 AM <JUNCTION> default-from-path [\??\C:\Users\username\Documents\src\rustup.rs\target\tests\running-test-5D1PNf\rustup-customsOflBt\custom-1]
0 File(s) 0 bytes
3 Dir(s) 127,863,406,592 bytes free
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).
stat /c/Users/username/Documents/src/rustup.rs/target/tests/running-test-5D1PNf/rustup-customsOflBt/
custom-1
stat: cannot stat '/c/Users/username/Documents/src/rustup.rs/target/tests/running-test-5D1PNf/rustup-customsOflBt/custom-1': No such file or directory
cargo clean fails:
cargo clean
error: failed to remove build artifact
Caused by:
failed to remove file `C:\Users\username\Documents\src\rustup.rs\target\tests\running-test-5D1PNf\rustupiIcEHF\toolchains\default-from-path`
Caused by:
Access is denied. (os error 5)
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 the remove_dir_all crate's equivalent API, and it does handle this correctly.
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.
Yes, the problem persists. The solution is to carefully go about every place where cargo decides how to delete a fs entry and check FileTypeExt::is_symlink_dir on Windows. I've dug a little bit, and it seems to me there are at least two places to patch: cargo_util::paths::remove_dir_all and CleanContext::rm_rf in cargo_clean.rs. I can come up with a patch.
BTW, std::fs::remove_dir_all does the right thing.
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: