I have been discussing this problem with Adam Kennedy and some other people at #email@example.com today:
Line 388 of Module/Install/Makefile.pm is a blank line, but the line after it is a simple two-arg open().
open MAKEFILE, "> $makefile_name" or
die "fix_up_makefile: Couldn't open $makefile_name: $!";
Side-note: I don't know why they use two-arg open there, but it is probably because Module::Install needs to work back to the stone-age of Perl.
Since the file was opened for read access a couple of lines above it got me thinking. This invalid argument message Windows gives you is its way of saying "hey, the file is locked somewhere else, you can't mess with it".
In the end I figured out that the bad guy here was my anti-virus (AVG). An extremely crude workaround I found that worked was to just put the entire Strawberry Perl in the anti-virus exclusion list. This solved the "invalid argument" message for me, and now my Module::Install-based CPAN modules install as they should.
This is obviously not a very good long-term solution. So this got me thinking a bit more. Who is really at fault here? Is it perl or AVG? Should AVG not allow open() to return before it is finished with its scanning stuff, or should perl handle open() for write differently on Windows, considering the OS itself forces write locking.
I'd really like to hear more about what you guys that know the perl internals have to say about this subject.
Update: Kenichi Ishigaki replied a bit later with a patch to Module::Install that works around the problem. He applied the web counter solution mentioned in perlfaq5 to the problem, and it worked for me. I guess it is now just to wait for Adam Kennedy to release a new version of Module::Install and file bugs against the CPAN modules that show problems on Windows with a message that they should upgrade their Module::Install version and issue a new release of their module.
Update2: Adam Kennedy has released Module::Install 0.98, which contains the patch. Please tell all CPAN module authors that use it to upgrade to the new version and Windows users will be very happy.
Comment from: kmx Visitor
Similar issue was reported (unfortunaltely not analysed) here:
And other known strawberry + antivirus clash (reported with Symantec and MS Essetials) is here:
Comment from: Member
I was the one who filed the first bug. I have left a comment there about my findings.
The second one is not related to the fix_up_makefile sub, so I don't know any other workaround for that one than to exclude the strawberry directory from antivirus scanning.
I guess this is one of the main disadvantages of M::I. When a bug is found, a truckload of modules need to be updated.
To my knowledge, this is the second time where there's a Windows-specific bug in M::I and a lot of modules break because of it.
I didn't experience these issues myself, though, as I don't use AVG.