Ken_Williams via RT wrote:
Show quoted text> I'm not quite clear on exactly what you're trying to do, though - could you provide a little more
> detail? Maybe some judicious use of the PERL5LIB environment variable would help?
Oh, dear. I hope I can explain this clearly.
I'm building a Perl tree for distribution to another site. I don't want
to build it on-site; I want to deploy it with all the appropriate
modules already installed. But I also can't build it in the location
that it's going to be deployed; e.g., I'm deploying it as /app/bin/perl
(well, /app/packages/perl-5.8.7/bin/perl, plus stow for linking), but I
can't build it in /app, because I'm building it on a machine which
already has a test installation of the remote site's code. So it gets
built in /project/staging/app/etc.
The problem arises when Module::Build tries to find the Perl executable
that's currently being used. find_perl_interpreter in Base.pm collects
the executable path correctly, but this executable requires a bunch of
-I directives in order to work (because it's being built in a location
other than the one where it'll be deployed). When we get down to
_perl_is_same, the config check fails to pass along the -I directives,
and so I get the config for the INSTALLED /app/bin/perl, rather than the
one I'm building. Here's the torture I inflicted on _perl_is_same to get
it to work:
sub _perl_is_same {
my ($self, $perl) = @_;
my @cmd = ($perl);
# When run from the perl core, @INC will include the directories
# where perl is yet to be installed. We need to reference the
# absolute path within the source distribution where it can find
# it's Config.pm This also prevents us from picking up a Config.pm
# from a different configuration that happens to be already
# installed in @INC.
# SAM 3/20/07: Not good enough. I need all the -I from the command line.
# Can't use $self->_added_to_inc, because that pretty much
# gives you infinite recursion.
if ($ENV{PERL_CORE}) {
push @cmd, '-I' .
File::Spec->catdir(File::Basename::dirname($perl), 'lib');
}
if ($ENV{PERL_MB_CONFIG_LIB}) {
# This is really gross. But we can't use _added_to_inc.
my $sep = $self->config('path_sep');
my @incs = split(/$sep/, $ENV{PERL_MB_CONFIG_LIB});
for my $inc ( @incs ) {
push @cmd, '-I' . $inc;
}
}
push @cmd, qw(-MConfig=myconfig -e print -e myconfig);
return $self->_backticks(@cmd) eq Config->myconfig;
}
You see that I added a whole new environment variable,
PERL_MB_CONFIG_LIB, because there's no way to get the -I directives from
the command line at this point that I could see. I'm not proud of this :-).
Hope this helps -
Sam