Description
Problem
cargo test
is failing intermittently for me on Windows.
PS C:\Users\jyn\src\cargo> cargo t --test testsuite warn_on_failure::no_warning_on_bin_failure
Finished test [unoptimized + debuginfo] target(s) in 0.25s
Running tests\testsuite\main.rs (target\debug\deps\testsuite-96440e92f452dc25.exe)
running 1 test
test warn_on_failure::no_warning_on_bin_failure ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 2811 filtered out; finished in 0.82s
PS C:\Users\jyn\src\cargo> cargo t --test testsuite warn_on_failure::no_warning_on_bin_failure
Finished test [unoptimized + debuginfo] target(s) in 0.26s
Running tests\testsuite\main.rs (target\debug\deps\testsuite-96440e92f452dc25.exe)
running 1 test
test warn_on_failure::no_warning_on_bin_failure ... FAILED
failures:
---- warn_on_failure::no_warning_on_bin_failure stdout ----
thread 'warn_on_failure::no_warning_on_bin_failure' panicked at 'failed to remove "C:\\Users\\jyn\\src\\cargo\\target\\tmp\\cit\\t0": Os { code:
5, kind: PermissionDenied, message: "Access is denied." }', crates\cargo-test-support\src\paths.rs:146:17
stack backtrace:
0: std::panicking::begin_panic_handler
at /rustc/f5559e338256f17ada6d82b429acc2dbd8facc9c/library\std\src\panicking.rs:584
1: core::panicking::panic_fmt
at /rustc/f5559e338256f17ada6d82b429acc2dbd8facc9c/library\core\src\panicking.rs:67
2: cargo_test_support::paths::impl$1::rm_rf
at .\crates\cargo-test-support\src\paths.rs:146
3: cargo_test_support::paths::init_root
at .\crates\cargo-test-support\src\paths.rs:81
4: testsuite::warn_on_failure::no_warning_on_bin_failure
at .\tests\testsuite\warn_on_failure.rs:77
5: testsuite::warn_on_failure::no_warning_on_bin_failure::closure$0
at .\tests\testsuite\warn_on_failure.rs:77
6: core::ops::function::FnOnce::call_once<testsuite::warn_on_failure::no_warning_on_bin_failure::closure_env$0,tuple$<> >
at /rustc/f5559e338256f17ada6d82b429acc2dbd8facc9c\library\core\src\ops\function.rs:250
7: core::ops::function::FnOnce::call_once
at /rustc/f5559e338256f17ada6d82b429acc2dbd8facc9c/library\core\src\ops\function.rs:250
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
failures:
warn_on_failure::no_warning_on_bin_failure
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 2811 filtered out; finished in 0.15s
Steps
Run cargo t --test testsuite warn_on_failure::no_warning_on_bin_failure
on windows MSVC until you get a test failure. This usually only takes 2 or 3 run to fail for me, and once it fails once it will continue to fail until I run rm -r -force target\\tmp\\cit\\t0
.
I am not sure what -force
is doing that CargoPathExt::rm_rf
isn't. Without force, rm
gives the same error as cargo. https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/remove-item?view=powershell-7.3#example-3-delete-hidden-read-only-files says it might be related to the index being read-only?
Some more info that may or may not be helpful:
PS C:\Users\jyn\src\cargo> rm -r C:\\Users\\jyn\\src\\cargo\\target\\tmp\\cit\\t0
rm : Cannot remove item C:\Users\jyn\src\cargo\target\tmp\cit\t0\home\AppData\Local\Microsoft\Windows\INetCache\IE\NJD6DELP: You do not have
sufficient access rights to perform this operation.
At line:1 char:1
+ rm -r C:\\Users\\jyn\\src\\cargo\\target\\tmp\\cit\\t0
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (NJD6DELP:DirectoryInfo) [Remove-Item], IOException
+ FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
rm : Cannot remove item C:\Users\jyn\src\cargo\target\tmp\cit\t0\home\AppData\Local\Microsoft\Windows\INetCache\IE\container.dat: You do not
have sufficient access rights to perform this operation.
At line:1 char:1
+ rm -r C:\\Users\\jyn\\src\\cargo\\target\\tmp\\cit\\t0
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (68ce435e0a43416537b0fee6dba5d9f338e038:FileInfo) [Remove-Item], IOException
+ FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
rm : Directory C:\Users\jyn\src\cargo\target\tmp\cit\t0\registry\.git\objects\c9 cannot be removed because it is not empty.
At line:1 char:1
that .git/objects
path apparently doesn't have write permissions set:
PS C:\Users\jyn\src\cargo> ls C:\Users\jyn\src\cargo\target\tmp\cit\t0\registry\.git\objects\
Directory: C:\Users\jyn\src\cargo\target\tmp\cit\t0\registry\.git\objects
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 4/27/2023 12:44 AM 25
d----- 4/27/2023 12:44 AM 26
d----- 4/27/2023 12:44 AM 51
d----- 4/27/2023 12:44 AM 67
d----- 4/27/2023 12:44 AM 9e
d----- 4/27/2023 12:44 AM a5
d----- 4/27/2023 12:44 AM bd
d----- 4/27/2023 12:44 AM c9
I tried switching to https://github.com/XAMPPRocky/remove_dir_all, but it didn't help.
Possible Solution(s)
No response
Notes
No response