Temp Directory "Bug"
So I wanted to install Dist::Zilla and give it try so I fired up the cpan client. A few of the tests failed in a dependency, Config::INI: http://www.nntp.perl.org/group/perl.cpan.testers/2010/08/msg7663252.html.
When I saw the failure, I traced it back to File::Temp::tempfile. I filled a bug report (https://rt.cpan.org/Ticket/Display.html?id=60340). Tim Jenness was quick to follow up on the bug and suggest that I try testing File::Spec::Win32 to see what it said with -T. (You'll see the results in the bug report previously mentioned.)
File::Spec::Win32 tries to use some weird paths that typically don't exist on Windows systems. Yes, C:\TEMP may or may not depending on number of variables such as version of Windows, what other software has been installed, etc.
Yes, I could create C:\system\temp or C:\TEMP and make it writable by me. Yes, I could make \ writable by me. Whether anyone agrees with me or not, I don't feel like I should have to. I also feel very strongly that neither should the new guy who wants to give this "perl thing" a try. CPAN module installs should just work.
So! Should I file the bug report? If so, where? File::Spec::Win32 for not using sane defaults? Strawberry Perl for not creating a valid temp directory? Windows itself? (Yeah, that last one made me laugh too.)
I believe the bug is from PathTools. If you read the documentation for File::Spec::Win32, it gives a list of everything that will be returned by tmpdir in order. It specifically states that if the environment is tainted, then none of the environment variables are used, but it should still return:
C:\system\temp
C:/temp
/tmp
/
The thing is, none of those exist in most Windows by default until the last one: /
The author should change the manual search paths to include the commonly present C:\Windows\temp (though users still can't normally write to it).
Unfortunately in Windows there is no global temporary directory that all users can write to by default (in other OSes there may be, like Linux has /tmp). Sadly with taint checking enabled, there is no way for File::Spec to get the user's writable temp location. The solution would be for the calling script to not use taint mode (since it is writing to the file system anyway) or at least untaint the temp environment variables in some way.
What it should do in -T mode, IMO, is to check %TEMP% against a logical regex for Windows filenames (there's none in Regex::Common except for file: URI's, or I'd recommend that), capture if that regex works, and then check for that directory's existence.
If anybody else does not submit a patch to do so, I might within the next few days (can't do it today)
Ticket 60406 opened:
https://rt.cpan.org/Ticket/Display.html?id=60406