From be1fa8db08d1995779592880cfe156f4351a89d5 Mon Sep 17 00:00:00 2001 From: brian d foy Date: Tue, 18 Oct 2016 16:02:51 -0400 Subject: [PATCH] For cpan -j, make the file an absolute path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is an additional fix for rt.cpan.org #116507. Since . will not be in @INC, we can't assume we are loading from the current directory (although that's a very likely situation for -j). Take whatever argument we get and expand it to an absolute path. Signed-off-by: Petr Písař --- lib/App/Cpan.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/App/Cpan.pm b/lib/App/Cpan.pm index 3ddcbe8..bc22cbc 100644 --- a/lib/App/Cpan.pm +++ b/lib/App/Cpan.pm @@ -289,7 +289,7 @@ use CPAN 1.80 (); # needs no test use Config; use autouse Cwd => qw(cwd); use autouse 'Data::Dumper' => qw(Dumper); -use File::Spec::Functions; +use File::Spec::Functions qw(catfile file_name_is_absolute rel2abs); use File::Basename; use Getopt::Std; @@ -1093,12 +1093,14 @@ sub _shell sub _load_config # -j { - my $file = shift || ''; + my $argument = shift; + + my $file = file_name_is_absolute( $argument ) ? $argument : rel2abs( $argument ); + croak( "cpan config file [$file] for -j does not exist!\n" ) unless -e $file; # should I clear out any existing config here? $CPAN::Config = {}; delete $INC{'CPAN/Config.pm'}; - croak( "Config file [$file] does not exist!\n" ) unless -e $file; my $rc = eval "require '$file'"; -- 2.13.6