Search code examples
perlcpanstrawberry-perlcpanm

Trying to force CPAN to install in specific directory for Strawberry Perl


I have a strawberry perl installation (v. 5.16.3) on a windows production box. I assume that many moons ago, somebody installed it on the C: drive and then just moved it to D:. I don't know, I wasn't there, however it works fine except when I'm trying to install modules. Using cpanm just throws the modules on the C: drive. No Good. @INC doesn't go there and the admin doesn't want anything on there anyway. I need them with Perl on the D:.

So, I tried using cpan and changing the directories:

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

It installed Email Simple in D:/strawberry/perl/lib - not perfect, but it works. Great! A few others go through the same. Go to install Module::Runtime

cpan> install Module::Runtime

and that goes in D:/strawberry/perl/lib/perl5. Huh? OK, not perfect, but my @INC includes D:/strawberry/perl/lib so this shouldn't be a problem, right? Go to install MooX::Types::MooseLike::Base

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

Won't install. Here's the cpan barf out:

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 

And this error repeats a few times, and all the test fail, etc. etc.

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

So, Questions....

(1) What do I need to do to put Module::Runtime in the correct place? My previous attempt to change directories worked for some, but not this one. I would prefer D:\strawberry\perl\site\lib - as it seems that cpanm would put it's modules there, but D:\strawberry\perl\lib would work fine too.

If we fix number (1) this doesn't matter, but I am curious if anyone has an answer:

(2) Why can't cpan find Module::Runtime, when it is in one of the subdirectories of @INC?

So I know that one answer is to reinstall strawberry in the correct spot, but this is a production box with constant running Perl scripts and no down time, so no, that isn't an option. They won't allow me to do that anyway.

Thanks in advance for the help.


Solution

  • The argument you provide to modules using ExtUtils::MakeMaker as their installer are inconsistent with the argument you provide to modules using Module::Build as their installer. Pick a scheme and use it consistently.

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

    Don't forget to tell Perl where to look for the modules.

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

    While that fixes your immediate problem, your approach of fixing the underlying problem isn't the best. Just clearing those values should have the module install in the correct location.

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

    Also make sure you don't override the installation location in env vars.

    set PERL_MM_OPT=
    set PERL_MB_OPT=
    

    Finally, You might want to check Config.pm and Config_heavy.pl for C: that need to be changed into D:.