Based on the thread about my file deletion heisenbug and the likelihood that a virus scanner was keeping files open preventing deletion, I propose the following patch specific to Windows. It's cut-and-paste from Base.pm, but adding a loop around rmtree.
I'd appreciate any feedback you might have on this hacky solution. Thanks, David === lib/Module/Build/Platform/Windows.pm ================================================================== --- lib/Module/Build/Platform/Windows.pm (revision 12568) +++ lib/Module/Build/Platform/Windows.pm (local) @@ -29,6 +29,25 @@ return $value; } +sub delete_filetree { + my $self = shift; + my $deleted = 0; + foreach (@_) { + next unless -e $_; + $self->log_info("Deleting $_\n"); + # try to delete up to 5 times (in case virus scanners are keeping files open) + for my $i ( 1 .. 5 ) { + File::Path::rmtree($_, 0, 0); + last if ! -e $_; + $self->log_info("Couldn't remove '$_'; trying again\n"); + sleep 1; + } + die "Couldn't remove '$_': $!\n" if -e $_; + $deleted++; + } + return $deleted; +} + sub ACTION_realclean { my ($self) = @_;