This queue is for tickets about the CPAN CPAN distribution.

Report information
The Basics
Id:
101224
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
tlhackque [...] yahoo.com
Cc:
AdminCc:

BugTracker
Severity:
(no value)
Broken in:
(no value)
Fixed in:
2.10



Subject: Uninitialized variable errors from CPAN::Distribution
Date: Wed, 31 Dec 2014 15:55:14 -0500
To: bug-CPAN@rt.cpan.org
From: tlhackque <tlhackque@yahoo.com>
CPAN::Distribution generates uninitialized variable errors from install, test commands.

Typical errors:
Use of uninitialized value in scalar assignment at .../CPAN/Distribution.pm line 1838.
Use of uninitialized value in scalar assignment at .../CPAN/Distribution.pm line 2138.

(Google will turn up dozens of examples of these errors in the wild.)

Environment:
Show quoted text
CPAN 2.05
perl, v5.8.8 built for i386-linux-thread-multi
Linux  2.6.22.14-72.fc6 #1 SMP Wed Nov 21 15:12:59 EST 2007 i686 i686 i386 GNU/Linux

This patch seems to fix the issues I've seen & should be safe.  There may be other occurrences of the idiom
local $ENV{x} = $ENV{x} where $ENV{x} doesn't exist or has an undef value.  These should be fixed.


--- /usr/lib/perl5/5.8.8/CPAN/Distribution.pm~  2014-04-09 17:04:35.000000000 -0400
+++ /usr/lib/perl5/5.8.8/CPAN/Distribution.pm   2014-12-31 15:32:26.000000000 -0500
@@ -1833,12 +1833,12 @@
         return;
     }

     $self->debug("Changed directory to $builddir") if $CPAN::DEBUG;

-    local $ENV{PERL_AUTOINSTALL} = $ENV{PERL_AUTOINSTALL};
-    local $ENV{PERL_EXTUTILS_AUTOINSTALL} = $ENV{PERL_EXTUTILS_AUTOINSTALL};
+    local $ENV{PERL_AUTOINSTALL} = $ENV{PERL_AUTOINSTALL} || '';
+    local $ENV{PERL_EXTUTILS_AUTOINSTALL} = $ENV{PERL_EXTUTILS_AUTOINSTALL} || '';
     $self->choose_MM_or_MB
         or return;

     my $configurator = $self->{configure} ? "Configure"
                      : $self->{modulebuild} ? "Build.PL"
@@ -1854,12 +1854,12 @@
     my $system;
     my $pl_commandline;
     if ($self->prefs->{pl}) {
         $pl_commandline = $self->prefs->{pl}{commandline};
     }
-    local $ENV{PERL} = $ENV{PERL};
-    local $ENV{PERL5_CPAN_IS_EXECUTING} = $ENV{PERL5_CPAN_IS_EXECUTING};
+    local $ENV{PERL} = defined $ENV{PERL}? $ENV{PERL} : $^X;
+    local $ENV{PERL5_CPAN_IS_EXECUTING} = $ENV{PERL5_CPAN_IS_EXECUTING} || '';
     local $ENV{PERL_MM_USE_DEFAULT} = 1 if $CPAN::Config->{use_prompt_default};
     local $ENV{NONINTERACTIVE_TESTING} = 1 if $CPAN::Config->{use_prompt_default};
     if ($pl_commandline) {
         $system = $pl_commandline;
         $ENV{PERL} = $^X;
@@ -2133,11 +2133,11 @@
     my $system;
     my $make_commandline;
     if ($self->prefs->{make}) {
         $make_commandline = $self->prefs->{make}{commandline};
     }
-    local $ENV{PERL} = $ENV{PERL};
+    local $ENV{PERL} = defined $ENV{PERL}? $ENV{PERL} : $^X;
     local $ENV{PERL_MM_USE_DEFAULT} = 1 if $CPAN::Config->{use_prompt_default};
     local $ENV{NONINTERACTIVE_TESTING} = 1 if $CPAN::Config->{use_prompt_default};
     if ($make_commandline) {
         $system = $make_commandline;
         $ENV{PERL} = CPAN::find_perl();

-- 
This communication may not represent my employer's views,
if any, on the matters discussed. 
Thanks, applied. I'll make a dev release asap, hopefully yomorrow.
It looks like this was applied/fixed with release 2.10. Thanks!


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

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.