Athanasius has asked for the wisdom of the Perl Monks concerning the following question:

I’m trying to install MooseX::App::Cmd 0.30 (the latest version) on my system:

but the test t/basic.t fails. I tracked down the error, but it turns out to be one I can reproduce independently:

1:40 >p5u v File::Temp File::Spec File::Temp C:\Perl\Strawberry\strawberry-perl-5.20.2.1-64bit-PDL\perl\lib +\File\Temp.pm: 0.2304 File::Spec C:\Perl\Strawberry\strawberry-perl-5.20.2.1-64bit-PDL\perl\lib +\File\Spec.pm: 3.48_01 1:40 >perl -MFile::Temp=tempfile -wE "my $fh = tempfile();" 1:40 >perl -T -MFile::Temp=tempfile -wE "my $fh = tempfile();" Error in tempfile() using template \XXXXXXXXXX: Could not create temp +file \97XyuKSMER: Permission denied at -e line 1. 1:40 >

(This is the same error message I get from basic.t.) Apparently File::Temp encounters a permission problem when running in taint mode (-T) on my system. The module documentation has only this to say about taint checks:

Taint mode
If you need to run code under taint mode, updating to the latest File::Spec is highly recommended.

— and I have the latest version (3.48_01) of File::Spec installed.

Which leaves me with these questions:

  1. Is File::Temp::tempfile() supposed to fail under taint mode in Windows? If so, is this documented anywhere? If not, is this a problem other monks have encountered?

  2. If it is supposed to fail, how is it that the CPAN Testers Matrix for MooseX-App-Cmd 0.30 shows a pass for Perl version 5.20.2 under mswin32?

Thanks for your help,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re: File::Temp::tempfile() fails under taint mode
by Corion (Patriarch) on Apr 08, 2015 at 16:28 UTC

    Is $ENV{TMPDIR} set? Most likely, that is considered tainted and causes the tests to fail?

      Thanks Corion, that’s a good idea, but it turns out it’s not set:

      2:44 >perl -wE "say $ENV{TMPDIR};" Use of uninitialized value in say at -e line 1. 2:48 >

      Following your lead, I also tried unsetting (deleting) $ENV{TEMP} and $ENV{TMP}, but this made no difference either.

      Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

        Did you try setting $ENV{TEMP} in your test?
Re: File::Temp::tempfile() fails under taint mode
by kennethk (Abbot) on Apr 08, 2015 at 17:38 UTC
    ActiveState perl 5.20.2 on Windows 7.1 passes your test. This sounds like a bug report.

    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

        If can be handy it fails on many Strawberry flavours, with different File::Temp version.
        -T -MFile::Temp=tempfile -wE "use Config; print qq(Perl $^V on $^O arc +h $Config{archname} File::Temp v. $File::Temp::VERSION\n);my $fh = te +mpfile();" ----------------------------------------······· | Error in tempfile() using \XXXXXXXXXX: Could not create temp file | \A3pfFkxOIt: Permission denied at -e line 1 | Perl v5.14.2 on MSWin32 arch MSWin32-x86-multi-thread File::Temp v +. 0.22 -------------------------------------------------------------------- +---······· ----------------------------------------······· | Error in tempfile() using template \XXXXXXXXXX: Could not create te +mp file | \tIFifxB347: Permission denied at -e line 1. | Perl v5.20.0 on MSWin32 arch MSWin32-x86-multi-thread-64int File:: +Temp v. | 0.2304 -------------------------------------------------------------------- +---······· ----------------------------------------······· | Error in tempfile() using \XXXXXXXXXX: Could not create temp file | \dr3rzHf4Yp: Permission denied at -e line 1. | Perl v5.16.2 on MSWin32 arch MSWin32-x64-multi-thread File::Temp v +. 0.22 -------------------------------------------------------------------- +---·······

        ..while it runs OK on an ancient 5.8 ActiveState
        L*
        There are no rules, there are no thumbs..
        Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

        As there is no problem with my running the test (including your command line code), but on your system you have isolated it to File::Temp with taint, I would say it is a bug for File::Temp. It is worth (as Discipulus points out) testing this across other Strawberry installs, particularly 5.18.


        #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.