New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CPAN.pm v1.59 chdirs before looking for perl #3332
Comments
From michael@shoebox.netCPAN.pm v1.59 chdirs before looking for an appropriate perl binary, causing bin/perl -MCPAN -e shell to -not- use bin/perl to run Makefile.PL. As far as I can tell, what's Perl Info
|
From @floatingatollOn Wed, 31 Jan 2001 michael@shoebox.net wrote:
At line 4188, it invokes CPAN::Distribution::perl to find a valid perl And you can't do the test before, because on MacOS, we skip the whole find Well, here's the cleanest way I could figure to do it. Andreas, will this R. $ PATH=/usr/bin bin/perl -MCPAN -e 'die CPAN::Distribution::perl' Inline Patch--- lib/CPAN.pm.orig Thu Feb 1 01:25:31 2001
+++ lib/CPAN.pm Thu Feb 1 01:31:19 2001
@@ -4173,10 +4173,10 @@
}
$CPAN::Frontend->myprint("\n CPAN.pm: Going to build ".$self->id."\n\n");
my $builddir = $self->dir;
- chdir $builddir or Carp::croak("Couldn't chdir $builddir: $!");
- $self->debug("Changed directory to $builddir") if $CPAN::DEBUG;
if ($^O eq 'MacOS') {
+ chdir $builddir or Carp::croak("Couldn't chdir $builddir: $!");
+ $self->debug("Changed directory to $builddir") if $CPAN::DEBUG;
ExtUtils::MM_MacOS::make($self);
return;
}
@@ -4186,6 +4186,8 @@
$system = $self->{'configure'};
} else {
my($perl) = $self->perl or die "Couldn\'t find executable perl\n";
+ chdir $builddir or Carp::croak("Couldn't chdir $builddir: $!");
+ $self->debug("Changed directory to $builddir") if $CPAN::DEBUG;
my $switch = "";
# This needs a handler that can be turned on or off:
# $switch = "-MExtUtils::MakeMaker ". |
From [Unknown Contact. See original ticket]On Thu, Feb 01, 2001 at 02:16:45AM -0800, Richard Soderberg wrote:
This is why I had difficulty crafting a patch, and finally gave up because I if ($self->{'configure'}) { doesn't the chdir still need to be done? Michael |
From @floatingatollOn Thu, 1 Feb 2001, Michael Fowler wrote:
Oh, blast. You're right. Andreas, this is starting to get a bit weird. Can you finish this R. |
From @schwernThe attached patch fixes this bug by the simple method of storing the Perl we started I've also taken the liberty of speeding up perl() by caching its result. |
From @schwernCPAN.pm.patch--- lib/CPAN.pm 2003/07/16 01:15:55 1.1
+++ lib/CPAN.pm 2003/07/16 01:25:38
@@ -53,6 +53,8 @@
$CPAN::Signal ||= 0;
$CPAN::Frontend ||= "CPAN::Shell";
$CPAN::Defaultsite ||= "ftp://ftp.perl.org/pub/CPAN";
+$CPAN::StartingPerl ||= CPAN::starting_perl();
+
package CPAN;
use strict qw(vars);
@@ -84,6 +86,21 @@
}
}
+
+#-> sub CPAN::starting_perl
+sub starting_perl {
+ my @candidates = ();
+ push @candidates, File::Spec->file_name_is_absolute($^X) ? $^X : "";
+ my $pwd = CPAN::anycwd();
+ push @candidates, File::Spec->catfile(CPAN::anycwd(), $^X);
+
+ my($perl) = grep { MM->maybe_command($_) } @candidates;
+
+ return $perl;
+}
+
+
+
#-> sub CPAN::shell ;
sub shell {
my($self) = @_;
@@ -4394,10 +4411,9 @@
#-> sub CPAN::Distribution::perl ;
sub perl {
my($self) = @_;
- my($perl) = File::Spec->file_name_is_absolute($^X) ? $^X : "";
- my $pwd = CPAN::anycwd();
- my $candidate = File::Spec->catfile($pwd,$^X);
- $perl ||= $candidate if MM->maybe_command($candidate);
+ return $self->{perl} if defined $self->{perl};
+
+ my $perl = $CPAN::StartingPerl;
unless ($perl) {
my ($component,$perl_name);
DIST_PERLNAME: foreach $perl_name ($^X, 'perl', 'perl5', "perl$]") {
@@ -4412,7 +4428,7 @@
}
}
}
- $perl;
+ $self->{perl} = $perl;
}
#-> sub CPAN::Distribution::make ;
|
From @smpeters
This is still a problem as of CPAN 1.76. |
From @schwern
This patch was never applied. I've attached a better patch which simply moves the find perl logic from |
From @schwernCPAN.pm.patch--- lib/CPAN.pm 2005/07/12 05:15:37 1.1
+++ lib/CPAN.pm 2005/07/12 05:37:26
@@ -54,6 +54,8 @@
$CPAN::Signal ||= 0;
$CPAN::Frontend ||= "CPAN::Shell";
$CPAN::Defaultsite ||= "ftp://ftp.perl.org/pub/CPAN";
+$CPAN::Perl ||= CPAN::find_perl();
+
package CPAN;
use strict qw(vars);
@@ -85,6 +87,7 @@
}
}
+
#-> sub CPAN::shell ;
sub shell {
my($self) = @_;
@@ -668,6 +671,32 @@
#-> sub CPAN::getcwd ;
sub getcwd {Cwd::getcwd();}
+#-> sub CPAN::find_perl ;
+sub find_perl {
+ my($perl) = File::Spec->file_name_is_absolute($^X) ? $^X : "";
+ my $pwd = CPAN::anycwd();
+ my $candidate = File::Spec->catfile($pwd,$^X);
+ $perl ||= $candidate if MM->maybe_command($candidate);
+
+ unless ($perl) {
+ my ($component,$perl_name);
+ DIST_PERLNAME: foreach $perl_name ($^X, 'perl', 'perl5', "perl$]") {
+ PATH_COMPONENT: foreach $component (File::Spec->path(),
+ $Config::Config{'binexp'}) {
+ next unless defined($component) && $component;
+ my($abs) = File::Spec->catfile($component,$perl_name);
+ if (MM->maybe_command($abs)) {
+ $perl = $abs;
+ last DIST_PERLNAME;
+ }
+ }
+ }
+ }
+
+ return $perl;
+}
+
+
#-> sub CPAN::exists ;
sub exists {
my($mgr,$class,$id) = @_;
@@ -4407,29 +4436,11 @@
}
}
-#-> sub CPAN::Distribution::perl ;
+
sub perl {
- my($self) = @_;
- my($perl) = File::Spec->file_name_is_absolute($^X) ? $^X : "";
- my $pwd = CPAN::anycwd();
- my $candidate = File::Spec->catfile($pwd,$^X);
- $perl ||= $candidate if MM->maybe_command($candidate);
- unless ($perl) {
- my ($component,$perl_name);
- DIST_PERLNAME: foreach $perl_name ($^X, 'perl', 'perl5', "perl$]") {
- PATH_COMPONENT: foreach $component (File::Spec->path(),
- $Config::Config{'binexp'}) {
- next unless defined($component) && $component;
- my($abs) = File::Spec->catfile($component,$perl_name);
- if (MM->maybe_command($abs)) {
- $perl = $abs;
- last DIST_PERLNAME;
- }
- }
- }
- }
- $perl;
+ return $CPAN::Perl;
}
+
#-> sub CPAN::Distribution::make ;
sub make {
|
From @steve-m-hayMichael G Schwern via RT wrote:
The (new) patch looks fine to me (not that I'm any CPAN.pm expert), but On my Win32 system, if I set the PATH to be just bin\perl -MCPAN -e shell followed by, say, "make Sort::Versions" works fine. (My perl binary is CPAN::Distribution::make does indeed chdir to the build directory before It continues to work even after I insert $^X = 'bin\\perl' at the start of CPAN::Distribution::perl to simulate an OS that doesn't It works because the DIST_PERLNAME: foreach loops succeed when $perl_name is 'perl' and $component is Why doesn't this work out for you? Radan Computational Ltd. The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems, please notify the sender immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email. |
From @schwernOn Tue, Jul 12, 2005 at 05:25:07PM +0100, Steve Hay wrote:
Because it should never do that search. In your example you got lucky $ cd ~/tmp/ This is perl, v5.8.6 built for darwin-thread-multi-2level <blah blah blah> $ ln -s /usr/bin/perl5.8.1 perl This is perl, v5.8.1-RC3 built for darwin-thread-multi-2level <bleh bleh> $ ./perl -MCPAN -e shell cpan shell -- CPAN exploration and modules installation (v1.76) cpan> test Text::Metaphone Checking if your kit is complete... Ding ding ding ding ding! I ran CPAN.pm with 5.8.1 but its building with -- |
From @steve-m-hayMichael G Schwern wrote:
It wasn't quite true. The relative Perl (bin\perl) didn't match It wasn't so much me getting lucky as you getting unlucky in your If you just changed PATH_COMPONENT: foreach $component (File::Spec->path(), to PATH_COMPONENT: foreach $component ($Config::Config{'binexp'}, then your example below would work wouldn't it? And it may also make sense for DIST_PERLNAME: foreach to be changed to DIST_PERLNAME: foreach since 'perl' is very likely to be found in $Config{binexp}. I agree that it makes much more sense to look for perl sooner rather
Radan Computational Ltd. The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems, please notify the sender immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email. |
From @schwernOn Wed, Jul 13, 2005 at 08:41:48AM +0100, Steve Hay wrote:
No, not if we want a chance to find the perl they ran with.
No, because the Perl I ran exists nowhere in $Config{binexp} nor PATH. Its
Ack! No! That means in this situation: $ which perl5.8.1 This is perl, v5.8.6 built for darwin-thread-multi-2level $ perl5.8.1 -MCPAN -e shell Its going to look for "perl" before "perl5.8.1" and thus probably pick up However, putting "perl$]" before "perl5" makes sense. Its better to check The ordering should probably be: $^X, -- |
From @steve-m-hayMichael G Schwern wrote:
OK, I give up. And I see you've sensibly moved this issue to a new Patch applied as change 25142. Radan Computational Ltd. The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems, please notify the sender immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email. |
@schwern - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#5634 (status was 'resolved')
Searchable as RT5634$
The text was updated successfully, but these errors were encountered: