Fri Apr 22 13:03:41 2011: Request 67681 was acted upon.
Transaction: Correspondence added by RSCHUPP
       Queue: PAR-Packer
     Subject: can'r wrtie file
   Broken in: 1.002
    Severity: Important
       Owner: RSCHUPP
  Requestors: morry.da...@sbcglobal.net
      Status: open
 Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=67681 >


On 2011-04-21 19:55:07, morrydavis wrote:
> C:\Users\morry\Desktop>pp -o c:/Users/morry/startup.exe startup.pl
> C:\Perl\site\bin/pp: Cannot write in this directory: No such file or
> directory
> 
> Not sure what directory it's trying to write in.

Your working directory.

There were several places where File::Temp::tempfile was 
called with a template parameter, but _without_ TMPDIR => 1,
so that it tries to generate the temporary file in the working
directory. File::Temp, you suck!

Please try the attached patch (apply it to an unpacked CPAN tarball,
then rebuild PAR::Packer).

Cheer, Roderich

diff -ubr a/lib/PAR/Packer.pm b/lib/PAR/Packer.pm
--- a/lib/PAR/Packer.pm	2010-11-21 17:39:23.000000000 +0100
+++ b/lib/PAR/Packer.pm	2011-04-22 18:42:22.932576126 +0200
@@ -191,9 +191,6 @@
         if (-e _) {
             $self->_die("Cannot write on $file: $!\n") unless -w _;
         }
-        unless (-w Cwd::cwd()) {
-            $self->_die("Cannot write in this directory: $!\n");
-        }
     }
 }
 
@@ -309,8 +306,8 @@
         $self->_warn("Using -e 'code' as input file, ignoring @$args\n")
           if (@$args and !$opt->{r});
 
-        my ($fh, $fake_input) =
-          File::Temp::tempfile("ppXXXXX", SUFFIX => ".pl", UNLINK => 1);
+        my ($fh, $fake_input) = File::Temp::tempfile(
+	    "ppXXXXX", SUFFIX => ".pl", TMPDIR => 1, UNLINK => 1);
 
         print $fh $opt->{e};
         close $fh;
@@ -633,7 +630,8 @@
         # Don't need to keep it, be safe with a tempfile.
 
         $self->{pack_attrib}{lose} = 1;
-        ($cfh, $par_file) = File::Temp::tempfile("ppXXXXX", SUFFIX => ".par");
+        ($cfh, $par_file) = File::Temp::tempfile(
+	    "ppXXXXX", SUFFIX => ".par", TMPDIR => 1, UNLINK => 1);
         close $cfh;    # See comment just below
     }
     $self->{par_file} = $par_file;
@@ -1299,9 +1297,8 @@
 
     $self->_vprint(0, "Generating a fresh 'parl'.");
     my ($fh, $filename) = File::Temp::tempfile(
-        "parlXXXXXXX",
-        SUFFIX => $Config{_exe},
-    );
+        "parlXXXXXXX", SUFFIX => $Config{_exe}, TMPDIR => 1, UNLINK => 1);
+    close $fh;
     
     my $success = $class->write_parl($filename);
     if (not $success) {
@@ -1349,10 +1346,7 @@
     my $cfh;
     my $fh = $self->_open($self->{parl});
     ($cfh, $self->{parl}) = File::Temp::tempfile(
-        "parlXXXX",
-        SUFFIX => ".exe",
-        UNLINK => 1,
-    );
+        "parlXXXX", SUFFIX => ".exe", TMPDIR => 1, UNLINK => 1);
     binmode($cfh);
 
     local $/;
diff -ubr a/lib/PAR/StrippedPARL/Base.pm b/lib/PAR/StrippedPARL/Base.pm
--- a/lib/PAR/StrippedPARL/Base.pm	2010-11-21 17:37:32.000000000 +0100
+++ b/lib/PAR/StrippedPARL/Base.pm	2011-04-22 18:39:58.688493279 +0200
@@ -53,10 +53,7 @@
 
     # write out to a temporary file first
     my ($fh, $tfile) = File::Temp::tempfile(
-        "parlXXXX",
-        SUFFIX => $Config::Config{_exe}||'',
-        DIR => File::Spec->tmpdir(),
-    );
+        "parlXXXX", SUFFIX => $Config::Config{_exe}||'', TMPDIR => 1);
     close $fh;
     # File::Temp, you suck!
 

Reply via email to