Subject: | unshift vs push onto @INC |
Assume I'm trying to install Dummy::Module from the CPAN shell, and
Dummy::Module depends on Dummy::Prereq 0.02, and Dummy::Prereq 0.01 is
available in $PERL5LIB (in a non-standard location, e.g. from
local::lib).
M::B makes a ./Build script that 'unshifts' all of the non-standard
directories from $PERL5LIB onto the front of @INC. M::B notices the
unsatisfied dependency. CPAN.pm gets Dummy::Prereq 0.02 and tests it,
but does not install it, because Dummy::Module has to be tested first.
Instead, it prepends ./blib/lib and ./blib/arch to $PERL5LIB so that the
updated versions will be found. It then tests Dummy::Module, using M::B.
However the ./Build script then unshifts onto @INC any non-standard
directories from $PERL5LIB that were present *before* Dummy::Prereq 0.02
was prepended to $PERL5LIB. I.e. if you install your modules to a non-
standard location, you cannot install any (M::B) module for which you
have an outdated prereq installed. I have been sending (many?) false
alarms from CPAN::Reporter::Smoker because of this.
It is not clear to me why @INC should be manipulated; @INC already
contains $PERL5LIB, but assuming it should be manipulated, 'push' seems
better. I changed this in the current git version, all tests still pass
(patch attached).
I was not clever enough to come up with a standalone test that would
cause M::B to fail, but I have a contrived example attached. The sh
script should not be executed directly (it contains an exec statement to
create a pristine environment), but rather copy-pasted into a terminal.
The session file shows the output that I see. You should be able to
reproduce this, as long as your systems's perl install has a reasonably
recent M::B.
This issue happens to me on:
64 bit Perl 5.8.8 with MB 0.38 on CentOS 5.5
32 bit Perl 5.12.3 with MB 0.36 on Fedora 14
I also do not believe this depends on local::lib, as M::B finds any non-
standard paths to prepend to @INC. I also believe that CPAN.pm is
behaving as it should, as it prepends $PERL5LIB so that the updated
prereqs can be found.
Subject: | module-build-script.sh |
Message body not shown because it is not plain text.
Subject: | module-build-script-session.txt |
Message body is not shown because it is too large.
Subject: | MB-INC.patch |
diff --git a/lib/Module/Build/Base.pm b/lib/Module/Build/Base.pm
index 3ffca3b..384bec6 100644
--- a/lib/Module/Build/Base.pm
+++ b/lib/Module/Build/Base.pm
@@ -1847,7 +1847,7 @@ BEGIN {
die ("Configuration seems to be out of date, please re-run 'perl Build.PL' again.\\n");
}
}
- unshift \@INC,
+ push \@INC,
(
$quoted_INC
);