This queue is for tickets about the CPAN CPAN distribution.

Report information
The Basics

Nobody in particular
adamk [...]

Broken in:
Fixed in:
(no value)

Subject: Provide a Win32-smart file deletion function
OK, this is something of a two-part issue, and can probably be solved a couple of ways. The main problem stems from Win32 not allowing you to delete a file that is in use. This means that the following occurs. 1. Can't upgrade PathTools via (Cmd.dll is locked) 2. Can't upgrade Term::ReadLine::Perl ( is locked) Running make install Cannot forceunlink C:\vanilla-perl\perl\site\lib\Term\ReadLine\ Perm ission denied at C:/vanilla-perl/perl/lib/File/ line 918 3. Cannot always remove previous build directories, because sometimes Windows holds a stale lock on the .dll (in my case, on IO.dll because the IO::Socket::INET tests hung). Basically, there's a whole bunch of reasons where you might have problems deleting files containing code on Windows. Thankfully, there seems to be a solution. While you cannot delete a file outright if in use, you CAN move or rename it! So, to fix this problem for at least the cases that is capable of fixing itself, we need to essentially find an unused temporary file name, and move the offending file well away from harm into the temp dir. Next time the temp directory gets cleaned out, presumably after a reboot down the track, then locked file gets cleared away. So, what you probably want to do is implement a utility function called remove or delete or something. If not Win32, unlink as normal. If Win32, try first to delete it normally inside an eval. If the eval dies with a "Permission denied" error, then implement the "move away" trick. If THAT fails, die as normal. Simply implementing the delete function is step 1, and then presumably changing the various bits of delete code to be use that abstracted delete (instead of unlink directly) is step 2.
I think this has been fixed in Module::Install or some dependency thereof, do not remember the details. Please reopen if this is still an issue for Thanks,

This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with to