Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the CPAN-Mini CPAN distribution.

Report information
The Basics
Id: 55272
Status: resolved
Priority: 0/
Queue: CPAN-Mini

People
Owner: Nobody in particular
Requestors: jkeen [...] verizon.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.576
Fixed in: (no value)



Subject: When use-d in other module, CPAN::Mini throws warnings and leads to test failures
Ricardo, Recently I uploaded to CPAN a new distribution called CPAN-Mini-Visit-Simple (http://search.cpan.org/~jkeenan/CPAN-Mini-Visit-Simple-0.002/). As you might suspect, it calls 'use CPAN::Mini'. I very quickly got back several reports from automated CPAN testers indicating that my tests were massively failing. See, for example, http://www.cpantesters.org/cpan/report/6892549. Here's an excerpt: PERL_DL_NONLAZY=1 /usr/perl5.10.1/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t Use of uninitialized value $config_file in concatenation (.) or string at /usr/perl5.10.1/lib/site_perl/5.10.1/CPAN/Mini.pm line 428. Use of uninitialized value $config_file in open at /usr/perl5.10.1/lib/site_perl/5.10.1/CPAN/Mini.pm line 430. Use of uninitialized value $config_file in concatenation (.) or string at /usr/perl5.10.1/lib/site_perl/5.10.1/CPAN/Mini.pm line 430. couldn't open config file : No such file or directory at /usr/perl5.10.1/lib/site_perl/5.10.1/CPAN/Mini.pm line 430. # Looks like you planned 13 tests but ran 1. # Looks like your test exited with 2 just after 1. t/001_new.t ....................... On the box on which I developed my distro, I have version 0.576 of CPAN::Mini installed. Searching in lib/CPAN/Mini/Visit/Simple.pm, I see in read_config(): 613 sub read_config { 614 my ($class) = @_; 615 616 my $filename = File::Spec->catfile($class->__homedir, '.minicpanrc'); 617 618 $filename = $class->__default_configfile unless -e $filename; 619 return unless -e $filename; 620 621 open my $config_file, '<', $filename 622 or die "couldn't open config file $filename: $!"; 623 I presume that '$filename' is the uninitialized value in question; that would explain the whitespace immediately before the ':' in the 'couldn't open config file' error message above. But how could $filename be uninitialized in lines 621-22. The file itself had to have existed to get past line 619! Is there something I'm not getting here? Thank you very much. Jim Keenan Info: perl -v This is perl, v5.10.1 (*) built for darwin-2level
From: jkeen [...] verizon.net
Further investigation: I installed the latest version of CPAN::Mini on a box that previously did not have that distribution installed and, not surprisingly, did not have a minicpan repository or ~/.minicpanrc file installed. package CPAN::Mini; our $VERSION = '1.100630'; Without creating a minicpan or a .minicpanrc, I then ran the attached program, handle_cpan_mini.pl. I got this output: $ perl handle_cpan_mini.pl Use of uninitialized value $config_file in concatenation (.) or string at /usr/local/lib/perl5/site_perl/5.10.1/CPAN/Mini.pm line 431. Using config from Use of uninitialized value $config_file in open at /usr/local/lib/perl5/site_perl/5.10.1/CPAN/Mini.pm line 434. Use of uninitialized value $config_file in concatenation (.) or string at /usr/local/lib/perl5/site_perl/5.10.1/CPAN/Mini.pm line 434. couldn't open config file : No such file or directory at /usr/local/lib/perl5/site_perl/5.10.1/CPAN/Mini.pm line 434. So the problem exists in the latest version of CPAN::Mini as well as the older version. Running code through the debugger, I eventually arrive here: DB<1> x defined $config_file 0 1 DB<2> x (-e $config_file) 0 undef DB<3> x $config_file 0 '/home/jimk/.minicpanrc' So the scalar variable $config_file gets defined whether the file it names exists or not! Perhaps the second patch attached could help. Thank you very much. Jim Keenan
Subject: config_file_value_initialization.diff
427a428,429 > die "CPAN::Mini configuration file not found: $!" > unless (defined $config_file and -e $config_file);
Subject: handle_cpan_mini.pl
#!/usr/local/bin/perl use strict; use warnings; use Data::Dumper;$Data::Dumper::Indent=1; use Carp; use feature ':5.10'; use CPAN::Mini; my $dataref = handle_cpan_mini({}); sub handle_cpan_mini { my $args = shift; my %data = (); if ( ! $args->{minicpan} ) { my %config = CPAN::Mini->read_config; if ( $config{local} ) { $data{minicpan} = $config{local}; } } else { $data{minicpan} = $args->{minicpan}; } return \%data; }
Thanks, I believe this was fixed by fe2a51ebe730babc57cdbe67daae4e9aadb5d8ae -- rjbs