I have a perl distribution I have built with Dist::Zilla , and so I do not have to contaminate my installed Perl's lib with the dependencies, I have used Carton to manage them.
Things work great in development, but when I run dzil test
or dzil release
and tests are run, then the dependencies are not found and tests fail because the modules cannot be loaded.
I have tried carton exec -- dzil test
and PERL5LIB=local/lib/perl5 dzil test
but I think that means i need to put all my Dist::Zilla deps into the cpanfile, which seems plain wrong (I do have Dist::Zilla and the deps I need installed in my perl's lib path).
Is there a better way?
我解决了:
export PERL5LIB=$PERL5LIB:/absolute/path/to/project/local/lib/perl5; dzil release
Here's what we need to do if we want to separate the dependencies between the develop and the package itself and install everything via carton (that is, do not keep them in the system). And at the same time when Dist::Zilla::Plugin::CPANFile overwrite package cpanfile.
carton exec dzil build
(Dist::Zilla::Plugin::CPANFile will automagically create cpanfile with projects dependencies) carton
carton exec dzil test
will work!Let me illustrate this as if all development dependencies are in the dev directory:
#!perl
chdir 'dev';
system 'carton'; # (1)
chdir ".."; # (2)
if (!-l "local") { symlink("dev/local", "local") or die $@; } # (2)
if (!-l "cpanfile.snapshot") { symlink("dev/cpanfile.snapshot", "cpanfile.snapshot") or die $@; } # (2)
system 'carton'; # (5)
print "done\n";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.