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