2

我在 Windows 生产盒上安装了草莓 perl(v.5.16.3)。我假设很多个月前,有人将它安装在 C: 驱动器上,然后将其移动到 D:。我不知道,我不在那里,但是它工作正常,除非我尝试安装模块。使用 cpanm 只是将模块扔到 C: 驱动器上。不好。@INC 不会去那里,管理员也不希望那里有任何东西。我需要它们在 D: 上使用 Perl。

所以,我尝试使用 cpan 并更改目录:

cpan> o conf mbuildpl_arg "--install_base D:/strawberry/perl"
    mbuildpl_arg       [--install_base D:strawberryperl]
commit: wrote 'D:\strawberry\perl\lib/CPAN/Config.pm'

cpan> o conf makepl_arg "PREFIX=D:/strawberry/perl"
    makepl_arg         [PREFIX=D:/strawberry/perl]
commit: wrote 'D:\strawberry\perl\lib/CPAN/Config.pm'

cpan> install Email::Simple

它在 D:/strawberry/perl/lib 中安装了 Email Simple - 并不完美,但它可以工作。伟大的!其他一些人也经历了同样的事情。去安装模块::运行时

cpan> install Module::Runtime

这在 D:/strawberry/perl/lib/perl5 中。嗯?好的,不完美,但我的@INC 包括 D:/strawberry/perl/lib 所以这应该不是问题,对吧?去安装 MooX::Types::MooseLike::Base

cpan> install MooX::Types::MooseLike::Base

不会安装。这是cpan barf:

cpan> install MooX::Types::MooseLike::Base
Running install for module 'MooX::Types::MooseLike::Base'
Running make for M/MA/MATEU/MooX-Types-MooseLike-0.29.tar.gz
Checksum for D:\strawberry\cpan\sources\authors\id\M\MA\MATEU\MooX-Types-MooseLike-0.29.tar.gz ok

  CPAN.pm: Building M/MA/MATEU/MooX-Types-MooseLike-0.29.tar.gz

Checking if your kit is complete...
Looks good
Warning: prerequisite Module::Runtime 0.014 not found.
... Detected uninstalled Perl.  Trying to continue.
Have \strawb~1\perl\lib
Want \strawberry\perl\lib
Writing Makefile for MooX::Types::MooseLike
Writing MYMETA.yml and MYMETA.json
---- Unsatisfied dependencies detected during ----
----  MATEU/MooX-Types-MooseLike-0.29.tar.gz  ----
    Module::Runtime [requires]
Running make test
  Delayed until after prerequisites
Running make install
  Delayed until after prerequisites
Running install for module 'Module::Runtime'
Running Build for Z/ZE/ZEFRAM/Module-Runtime-0.014.tar.gz
  Has already been unwrapped into directory D:\strawberry\cpan\build\Module-Runtime-0.014-yHdcFp
  Has already been made
Running Build test
  Has already been tested successfully
Running Build install
  Already done
Running make for M/MA/MATEU/MooX-Types-MooseLike-0.29.tar.gz
  Has already been unwrapped into directory D:\strawberry\cpan\build\MooX-Types-MooseLike-0.29-UaWuDZ

  CPAN.pm: Building M/MA/MATEU/MooX-Types-MooseLike-0.29.tar.gz

Warning: Prerequisite 'Module::Runtime => 0.014' for 'MATEU/MooX-Types-MooseLike-0.29.tar.gz' already built but the resu
lt looks suspicious. Skipping another build attempt, to prevent looping endlessly.
cp lib/MooX/Types/MooseLike.pm blib\lib\MooX\Types\MooseLike.pm
cp lib/MooX/Types/MooseLike/Base.pm blib\lib\MooX\Types\MooseLike\Base.pm
  MATEU/MooX-Types-MooseLike-0.29.tar.gz
  D:\strawberry\c\bin\dmake.exe -- OK
Running make test
D:\strawberry\perl\bin\perl.exe "-ID:/strawberry/perl/lib" "-ID:/strawberry/perl/lib" "-MExtUtils::Command::MM" "-e" "te
st_harness(0, 'blib\lib', 'blib\arch')" t/*.t
t/basic.t ........................ Can't locate Module/Runtime.pm in @INC (@INC contains: D:\strawberry\cpan\build\MooX-
Types-MooseLike-0.29-UaWuDZ\blib\lib D:\strawberry\cpan\build\MooX-Types-MooseLike-0.29-UaWuDZ\blib\arch D:/strawberry/p
erl/lib D:/strawberry/perl/site/lib/MSWin32-x86-multi-thread D:/strawberry/perl/site/lib D:/strawberry/perl/vendor/lib D
:/strawberry/perl/lib .) at D:/strawberry/perl/lib/Moo/_Utils.pm line 23.
BEGIN failed--compilation aborted at D:/strawberry/perl/lib/Moo/_Utils.pm line 23.
Compilation failed in require at D:/strawberry/perl/lib/Moo.pm line 13.
BEGIN failed--compilation aborted at D:/strawberry/perl/lib/Moo.pm line 13.
Compilation failed in require at t/basic.t line 4.
BEGIN failed--compilation aborted at t/basic.t line 4.
t/basic.t ........................ Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
t/builder.t ...................... Can't locate Module/Runtime.pm in @INC (@INC contains: D:\strawberry\cpan\build\MooX-
Types-MooseLike-0.29-UaWuDZ\blib\lib D:\strawberry\cpan\build\MooX-Types-MooseLike-0.29-UaWuDZ\blib\arch D:/strawberry/perl/lib D:/strawberry/perl/site/lib/MSWin32-x86-multi-thread D:/strawberry/perl/site/lib D:/strawberry/perl/vendor/lib 

而且这个错误重复了几次,所有的测试都失败了,等等。

Files=14, Tests=0,  1 wallclock secs ( 0.06 usr +  0.03 sys =  0.09 CPU)
Result: FAIL
Failed 14/14 test programs. 0/0 subtests failed.
dmake.exe:  Error code 130, while making 'test_dynamic'
  MATEU/MooX-Types-MooseLike-0.29.tar.gz
one dependency not OK (Module::Runtime); additionally test harness failed
  D:\strawberry\c\bin\dmake.exe test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
  reports MATEU/MooX-Types-MooseLike-0.29.tar.gz
Running make install
  make test had returned bad status, won't install without force
Stopping: 'install' failed for 'M/MA/MATEU/MooX-Types-MooseLike-0.29.tar.gz'.
Failed during this command:
 MATEU/MooX-Types-MooseLike-0.29.tar.gz       : make_test NO one dependency not OK (Module::Runtime); additionally test
harness failed

所以,问题....

(1) 我需要做什么才能将 Module::Runtime 放在正确的位置?我之前更改目录的尝试对某些人有效,但对这个无效。我更喜欢 D:\strawberry\perl\site\lib - 因为 cpanm 似乎会将它的模块放在那里,但 D:\strawberry\perl\lib 也可以正常工作。

如果我们修复数字 (1) 这并不重要,但我很好奇是否有人有答案:

(2) 为什么当Module::Runtime 位于@INC 的子目录之一时,cpan 找不到?

所以我知道一个答案是在正确的位置重新安装草莓,但这是一个持续运行 Perl 脚本并且没有停机时间的生产盒,所以不,这不是一个选项。无论如何,他们不会允许我这样做。

在此先感谢您的帮助。

4

1 回答 1

1

您为使用 ExtUtils::MakeMaker 作为其安装程序的模块提供的参数与您为使用 Module::Build 作为其安装程序的模块提供的参数不一致。选择一个方案并始终如一地使用它。

o conf makepl_arg "INSTALL_BASE=D:/strawberry/perl_modules"
o conf mbuildpl_arg "--install_base D:/strawberry/perl_modules"

不要忘记告诉 Perl 在哪里寻找模块。

set PERL5LIB=D:/strawberry/perl_modules/lib/perl5

虽然这可以解决您的直接问题,但您解决潜在问题的方法并不是最好的。只需清除这些值即可将模块安装在正确的位置。

o conf makepl_arg ""
o conf mbuildpl_arg ""
set PERL5LIB=

还要确保不要覆盖 env vars 中的安装位置。

set PERL_MM_OPT=
set PERL_MB_OPT=

最后,您可能需要检查Config.pmConfig_heavy.pl需要C:将其更改为D:.

于 2016-12-02T15:47:58.200 回答