8

我有一个使用Dist::Zilla构建的 perl 发行版,因此我不必用依赖项污染我安装的 Perl 的库,我使用Carton来管理它们。

事情在开发中运行良好,但是当我运行dzil testdzil release运行测试时,找不到依赖项并且测试失败,因为无法加载模块。

我已经尝试过carton exec -- dzil testPERL5LIB=local/lib/perl5 dzil test但我认为这意味着我需要将我所有的 Dist::Zilla deps 放入 cpanfile,这似乎完全错误(我确实在我的 perl 的 lib 路径中安装了 Dist::Zilla 和我需要的 deps)。

有没有更好的办法?

4

2 回答 2

2

我解决了它:

export PERL5LIB=$PERL5LIB:/absolute/path/to/project/local/lib/perl5; dzil release
于 2014-07-02T12:15:55.460 回答
1

如果我们想分离开发和包本身之间的依赖关系并通过carton安装所有东西(即不要将它们保留在系统中),这就是我们需要做的事情。同时当 Dist::Zilla::Plugin::CPANFile 覆盖包 cpanfile。

  1. 通过 cpanfile 使用 carton 在单独的路径上安装所有 Dist::Zilla 和其他开发依赖项
  2. 将这些本地库链接到主项目
  3. 在这里你在你的项目中做一些事情,例如,添加更多的依赖项
  4. carton exec dzil build(Dist::Zilla::Plugin::CPANFile 将自动创建带有项目依赖项的 cpanfile)
  5. 像往常一样安装它们carton
  6. 从现在开始carton exec dzil test将工作!

让我来说明这一点,就好像所有开发依赖项都在 dev 目录中一样:

#!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";
于 2022-01-09T20:54:16.403 回答