Skip Menu |

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

Report information
The Basics
Id: 94963
Status: new
Priority: 0/
Queue: CPAN-Inject

People
Owner: Nobody in particular
Requestors: ppisar [...] redhat.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.14
Fixed in: (no value)



Subject: t/02_main.t fails if CPAN has not been preconfigured
If $HOME/.cpan does not exists, CPAN called by CPAN::Inject will initialize the configurations, install local::lib and returns to the CPAN::Inject which fails: [...] You can re-run configuration any time with 'o conf init' in the CPAN shell ok 13 # skip Current user owns CPAN::Config ok 14 - An object of class 'CPAN::Inject' isa 'CPAN::Inject' ok 15 - ->author ok The directory 't/sources' does not exist at t/02_main.t line 100. # Looks like you planned 24 tests but ran 15. # Looks like your test exited with 2 just after 15. Dubious, test returned 2 (wstat 512, 0x200) Failed 9/24 subtests This is because current working directory has been changed unexpectedly into $HOME/.cpan/build/local-lib-2.000011-GyARJh (the local-lib build directory). Thus CPAN::Inject cannot find t/sources anymore. Is it a bug in the CPAN::Inject, CPAN, or local::lib build script?
From: ppisar [...] redhat.com
Dne St 23.dub.2014 09:36:20, ppisar napsal(a): Show quoted text
> This is because current working directory has been changed > unexpectedly into $HOME/.cpan/build/local-lib-2.000011-GyARJh (the > local-lib build directory). Thus CPAN::Inject cannot find t/sources > anymore. > > Is it a bug in the CPAN::Inject, CPAN, or local::lib build script?
There is a similar bug report #52520 against CPAN.
From: ppisar [...] redhat.com
Dne St 23.dub.2014 09:36:20, ppisar napsal(a): Show quoted text
> If $HOME/.cpan does not exists, CPAN called by CPAN::Inject will > initialize the configurations, install local::lib and returns to the > CPAN::Inject which fails:
A work-around is attached. -- Petr
Subject: CPAN-Inject-1.14-Restore-working-directory-after-loading-CPAN-configu.patch
From 77e5e5d05f5b4df313b89ed96d5cc2e7d335dac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com> Date: Thu, 24 Apr 2014 11:20:51 +0200 Subject: [PATCH] Restore working directory after loading CPAN configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Uninitialized CPAN can install local::lib and change working directory into last build directory (CPAN RT#52520). This is a work-around to restore the directory back. <https://rt.cpan.org/Public/Bug/Display.html?id=94963> Signed-off-by: Petr Písař <ppisar@redhat.com> --- Makefile.PL | 1 + lib/CPAN/Inject.pm | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/Makefile.PL b/Makefile.PL index 9c49730..e1e8ee8 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -2,6 +2,7 @@ use inc::Module::Install 1.00; name 'CPAN-Inject'; all_from 'lib/CPAN/Inject.pm'; +requires 'Cwd' => '0'; requires 'File::Spec' => '0.80'; requires 'File::stat' => '1.00'; requires 'File::chmod' => '0.30'; diff --git a/lib/CPAN/Inject.pm b/lib/CPAN/Inject.pm index faec14c..86cf9ea 100644 --- a/lib/CPAN/Inject.pm +++ b/lib/CPAN/Inject.pm @@ -205,6 +205,10 @@ sub from_cpan_config { # Load the CPAN module require CPAN; + # Remember working directory in case CPAN will change it, RT#94963 + require Cwd; + my $origin_working_directory = Cwd::getcwd; + # Support for different mechanisms depending on the version # of CPAN that is in use. if ( defined $CPAN::HandleConfig::VERSION ) { @@ -213,6 +217,14 @@ sub from_cpan_config { CPAN::Config->load; } + # Restore working directory in case CPAN has changed it, RT#94963 + if ($origin_working_directory ne Cwd::getcwd) { + chdir $origin_working_directory or + warn "CPAN changed working directory " . + "and later restoration to " . + "$origin_working_directory failed: $!"; + } + # Get the sources directory my $sources = undef; if ( defined $CPAN::Config->{keep_source_where} ) { -- 1.9.0