Closed p5pRT closed 22 years ago
When I ran CPAN shell a la cpan\, I got the following error. The comment in the code which call the error message says this "Should never happen" !
Robin
% perl5.7.2 -MCPAN -e shell Cannot open >/home/rmb1/.cpan/CPAN/MyConfig.pm at /opt/perl/lib/5.7.2/CPAN.pm line 1156 CPAN::Config::load('CPAN::Config') called at /opt/perl/lib/5.7.2/CPAN.pm line 88 CPAN::shell() called at -e line 1
This bug occurs when an installed perl does not have CPAN/Config.pm and a user runs cpan when he can not create CPAN/Config.pm and has a read only MyConfig.pm (my MyConfig.pm is under RCS).
I have included a patch which merges some (attemptedly) repeated code\, so that a change made to the first repeat also occurs in the second\, which fixes this bug.
Robin
From perlbug@rfi.net Mon Jan 28 13:05:37 2002 Date: 28 Jan 2002 13:05:33 -0000 From: perlbug@onion.perl.org Subject: Perlbug - reminder of bug(20010713.003) status X-Errors-To: perlbug@rfi.net To: rmb1@cise.npl.co.uk X-Perlbug: Perlbug(tron) v2.92 Content-Length: 1085
This is a Perlbug status\(open\) reminder for an outstanding bug\, a report for which is appended at the base of this email\. If the the status of this bug is in any way incorrect\, please inform an administrator of the Perlbug system\. Further data relating to this bug\(20010713\.003\) may be found at​: http​://bugs\.perl\.org/index\.html/perlbug\.cgi?req=bidmid&bidmid=20010713\.003 The group\(library\) of administrators responsible for this bug is​: http​://bugs\.perl\.org/index\.html/perlbug\.cgi?req=group\_id&group\_id=2 For email help send an email to​: To​: bugdb@​perl\.org Subject​: \-H Bug report \(current status\) follows​:
Bug: 20010713.003
Subject: CPAN configuration failed From: Robin Barker \rmb1@​cise\.npl\.co\.uk Created: 2001-07-13 09:50:41 Modified: 2001-07-13 09:50:41Status: open Severity: medium OS names: solaris Group: library Version: Fixed in:
Message ids: 0
Patch ids: 0
Test ids: 0
Note ids: 0
Change ids: 0
Parent ids: 0
Child ids: 0
Address ids: 1
Patch:
--- lib/CPAN.pm
+++ lib/CPAN.pm
@@ -1095\,6 +1095\,36 @@
1;
}
+# This is a piece of repeated code that is abstracted here for
+# maintainability. RMB
+#
+sub _configpmtest {
+ my($configpmdir\, $configpmtest) = @_;
+ if (-w $configpmtest) {
+ return $configpmtest;
+ } elsif (-w $configpmdir) {
+ #_#_# following code dumped core on me with 5.003_11\, a.k.
+ my $configpm_bak = "$configpmtest.bak";
+ unlink $configpm_bak if -f $configpm_bak;
+ if( -f $configpmtest ) {
+ if( rename $configpmtest\, $configpm_bak ) {
+ $CPAN::Frontend->mywarn(\<\<END)
+Old configuration file $configpmtest
+ moved to $configpm_bak
+END
+ }
+ }
+ my $fh = FileHandle->new;
+ if ($fh->open(">$configpmtest")) {
+ $fh->print("1;\n");
+ return $configpmtest;
+ } else {
+ # Should never happen
+ Carp::confess("Cannot open >$configpmtest");
+ }
+ } else { return }
+}
+
#-> sub CPAN::Config::load ;
sub load {
my($self) = shift;
@@ -1125\,39 +1155\,14 @@
my($configpmdir) = File::Spec->catdir($path_to_cpan\,"CPAN");
my($configpmtest) = File::Spec->catfile($configpmdir\,"Config.pm");
if (-d $configpmdir or File::Path::mkpath($configpmdir)) {
- if (-w $configpmtest) {
- $configpm = $configpmtest;
- } elsif (-w $configpmdir) {
- #_#_# following code dumped core on me with 5.003_11\, a.k.
- unlink "$configpmtest.bak" if -f "$configpmtest.bak";
- rename $configpmtest\, "$configpmtest.bak" if -f $configpmtest;
- my $fh = FileHandle->new;
- if ($fh->open(">$configpmtest")) {
- $fh->print("1;\n");
- $configpm = $configpmtest;
- } else {
- # Should never happen
- Carp::confess("Cannot open >$configpmtest");
- }
- }
+ $configpm = _configpmtest($configpmdir\,$configpmtest);
}
unless ($configpm) {
$configpmdir = File::Spec->catdir($ENV{HOME}\,".cpan"\,"CPAN");
File::Path::mkpath($configpmdir);
$configpmtest = File::Spec->catfile($configpmdir\,"MyConfig.pm");
- if (-w $configpmtest) {
- $configpm = $configpmtest;
- } elsif (-w $configpmdir) {
- #_#_# following code dumped core on me with 5.003_11\, a.k.
- my $fh = FileHandle->new;
- if ($fh->open(">$configpmtest")) {
- $fh->print("1;\n");
- $configpm = $configpmtest;
- } else {
- # Should never happen
- Carp::confess("Cannot open >$configpmtest");
- }
- } else {
+ $configpm = _configpmtest($configpmdir\,$configpmtest);
+ unless ($configpm) {
Carp::confess(qq{WARNING: CPAN.pm is unable to }.
qq{create a configuration file.});
}
End of patch
-- Robin Barker | Email: Robin.Barker@npl.co.uk CMSC\, Building 10\, | Phone: +44 (0) 20 8943 7090 National Physical Laboratory\, | Fax: +44 (0) 20 8977 7091 Teddington\, Middlesex\, UK. TW11 OLW | WWW: http://www.npl.co.uk
This bug occurs when an installed perl does not have CPAN/Config.pm and a user runs cpan when he can not create CPAN/Config.pm and has a read only MyConfig.pm (my MyConfig.pm is under RCS).
I have included a patch which merges some (attemptedly) repeated code\, so that a change made to the first repeat also occurs in the second\, which fixes this bug.
Robin
From perlbug@rfi.net Mon Jan 28 13:05:37 2002 Date: 28 Jan 2002 13:05:33 -0000 From: perlbug@onion.perl.org Subject: Perlbug - reminder of bug(20010713.003) status X-Errors-To: perlbug@rfi.net To: rmb1@cise.npl.co.uk X-Perlbug: Perlbug(tron) v2.92 Content-Length: 1085
This is a Perlbug status\(open\) reminder for an outstanding bug\, a report for which is appended at the base of this email\. If the the status of this bug is in any way incorrect\, please inform an administrator of the Perlbug system\. Further data relating to this bug\(20010713\.003\) may be found at​: http​://bugs\.perl\.org/index\.html/perlbug\.cgi?req=bidmid&bidmid=20010713\.003 The group\(library\) of administrators responsible for this bug is​: http​://bugs\.perl\.org/index\.html/perlbug\.cgi?req=group\_id&group\_id=2 For email help send an email to​: To​: bugdb@​perl\.org Subject​: \-H Bug report \(current status\) follows​:
Bug: 20010713.003
Subject: CPAN configuration failed From: Robin Barker \rmb1@​cise\.npl\.co\.uk Created: 2001-07-13 09:50:41 Modified: 2001-07-13 09:50:41Status: open Severity: medium OS names: solaris Group: library Version: Fixed in:
Message ids: 0
Patch ids: 0
Test ids: 0
Note ids: 0
Change ids: 0
Parent ids: 0
Child ids: 0
Address ids: 1
Patch:
--- lib/CPAN.pm
+++ lib/CPAN.pm
@@ -1095\,6 +1095\,36 @@
1;
}
+# This is a piece of repeated code that is abstracted here for
+# maintainability. RMB
+#
+sub _configpmtest {
+ my($configpmdir\, $configpmtest) = @_;
+ if (-w $configpmtest) {
+ return $configpmtest;
+ } elsif (-w $configpmdir) {
+ #_#_# following code dumped core on me with 5.003_11\, a.k.
+ my $configpm_bak = "$configpmtest.bak";
+ unlink $configpm_bak if -f $configpm_bak;
+ if( -f $configpmtest ) {
+ if( rename $configpmtest\, $configpm_bak ) {
+ $CPAN::Frontend->mywarn(\<\<END)
+Old configuration file $configpmtest
+ moved to $configpm_bak
+END
+ }
+ }
+ my $fh = FileHandle->new;
+ if ($fh->open(">$configpmtest")) {
+ $fh->print("1;\n");
+ return $configpmtest;
+ } else {
+ # Should never happen
+ Carp::confess("Cannot open >$configpmtest");
+ }
+ } else { return }
+}
+
#-> sub CPAN::Config::load ;
sub load {
my($self) = shift;
@@ -1125\,39 +1155\,14 @@
my($configpmdir) = File::Spec->catdir($path_to_cpan\,"CPAN");
my($configpmtest) = File::Spec->catfile($configpmdir\,"Config.pm");
if (-d $configpmdir or File::Path::mkpath($configpmdir)) {
- if (-w $configpmtest) {
- $configpm = $configpmtest;
- } elsif (-w $configpmdir) {
- #_#_# following code dumped core on me with 5.003_11\, a.k.
- unlink "$configpmtest.bak" if -f "$configpmtest.bak";
- rename $configpmtest\, "$configpmtest.bak" if -f $configpmtest;
- my $fh = FileHandle->new;
- if ($fh->open(">$configpmtest")) {
- $fh->print("1;\n");
- $configpm = $configpmtest;
- } else {
- # Should never happen
- Carp::confess("Cannot open >$configpmtest");
- }
- }
+ $configpm = _configpmtest($configpmdir\,$configpmtest);
}
unless ($configpm) {
$configpmdir = File::Spec->catdir($ENV{HOME}\,".cpan"\,"CPAN");
File::Path::mkpath($configpmdir);
$configpmtest = File::Spec->catfile($configpmdir\,"MyConfig.pm");
- if (-w $configpmtest) {
- $configpm = $configpmtest;
- } elsif (-w $configpmdir) {
- #_#_# following code dumped core on me with 5.003_11\, a.k.
- my $fh = FileHandle->new;
- if ($fh->open(">$configpmtest")) {
- $fh->print("1;\n");
- $configpm = $configpmtest;
- } else {
- # Should never happen
- Carp::confess("Cannot open >$configpmtest");
- }
- } else {
+ $configpm = _configpmtest($configpmdir\,$configpmtest);
+ unless ($configpm) {
Carp::confess(qq{WARNING: CPAN.pm is unable to }.
qq{create a configuration file.});
}
End of patch
-- Robin Barker | Email: Robin.Barker@npl.co.uk CMSC\, Building 10\, | Phone: +44 (0) 20 8943 7090 National Physical Laboratory\, | Fax: +44 (0) 20 8977 7091 Teddington\, Middlesex\, UK. TW11 OLW | WWW: http://www.npl.co.uk
On Wed\, Jan 30\, 2002 at 11:58:33AM +0000\, Robin Barker wrote:
This bug occurs when an installed perl does not have CPAN/Config.pm and a user runs cpan when he can not create CPAN/Config.pm and has a read only MyConfig.pm (my MyConfig.pm is under RCS).
I have included a patch which merges some (attemptedly) repeated code\, so that a change made to the first repeat also occurs in the second\, which fixes this bug.
Thanks\, applied.
-- $jhi++; # http://www.iki.fi/jhi/ # There is this special biologist word we use for 'stable'. # It is 'dead'. -- Jack Cohen
On Wed\, Jan 30\, 2002 at 11:58:33AM +0000\, Robin Barker wrote:
This bug occurs when an installed perl does not have CPAN/Config.pm and a user runs cpan when he can not create CPAN/Config.pm and has a read only MyConfig.pm (my MyConfig.pm is under RCS).
I have included a patch which merges some (attemptedly) repeated code\, so that a change made to the first repeat also occurs in the second\, which fixes this bug.
Thanks\, applied.
-- $jhi++; # http://www.iki.fi/jhi/ # There is this special biologist word we use for 'stable'. # It is 'dead'. -- Jack Cohen
Robin Barker wrote: [snip]
+ my $fh = FileHandle->new; + if ($fh->open(">$configpmtest")) { + $fh->print("1;\n");
I'm just a bit curious... is there any reason you're using FileHandle\, rather than IO::File ?
-- There's a wild Fandango loose in the theater!
Robin Barker wrote: [snip]
+ my $fh = FileHandle->new; + if ($fh->open(">$configpmtest")) { + $fh->print("1;\n");
I'm just a bit curious... is there any reason you're using FileHandle\, rather than IO::File ?
It was in the piece of repeated code I copies and unrepeated.
The rest of CPAN.pm use FileHandle rather than IO::* no doubt for histerical (and supposed backward compatibility) raisins.
Robin
-- Robin Barker | Email: Robin.Barker@npl.co.uk CMSC\, Building 10\, | Phone: +44 (0) 20 8943 7090 National Physical Laboratory\, | Fax: +44 (0) 20 8977 7091 Teddington\, Middlesex\, UK. TW11 OLW | WWW: http://www.npl.co.uk
Fixed by patch supplied by Robin Barker\, applied by Jarkko
rmb1@cise.npl.co.uk - Status changed from 'open' to 'resolved'
Migrated from rt.perl.org#7275 (status was 'resolved')
Searchable as RT7275$