Open chazmcgarvey opened 6 years ago
Just hit this on a seperate usecase.
@INC
in a path ( eg: ./dev-inc/
)./dev-inc/auto/share/dist/
@INC
tweaking plugin, or you're employing dist.pl
with a more explicit and literal @INC
modification.This is somewhat "fine" as long as all dependencies and assets are resolved during plugin loading, inside this block:
However, any dependency/sharedir loading that occurs outside the plugin loading phase becomes utterly broken.
Which makes bundling libraries in an "only non-XS deps, local lib" impossible.
I have a seeming workaround, but its a bit obscene and I doubt many can utilize it...
my $libdir;
my $devlibdir;
BEGIN {
$libdir = path('./lib')->realpath->stringify;
$devlibdir = path('./dev-inc')->realpath->stringify;
*_ensure_devel_inc = sub {
require lib;
if ( not grep { $_ eq $libdir } @INC ) {
lib->import($libdir);
}
if ( not grep { $_ eq $devlibdir } @INC ) {
lib->import($devlibdir);
}
};
_ensure_devel_inc();
}
BEGIN {
# Oh god: https://github.com/rjbs/Config-MVP/issues/14
require Config::MVP::Assembler;
my $old = \&Config::MVP::Assembler::sequence;
my $replacement = sub {
_ensure_devel_inc();
my $guard = guard { _ensure_devel_inc(); undef };
$old->(@_)
};
{
no strict 'refs';
no warnings 'redefine';
*Config::MVP::Assembler::sequence = $replacement;
}
}
Localizing
@INC
(3966df41) breaks thisDist::Zilla
use case:since munging happens after
read_config
.