Search code examples
perlconfigurationinstallationcpancpanm

How do I convince cpanminus to install modules in lib/ instead of lib/perl5?


I'm installing a bunch of modules listed in a cpanfile into a self-contained directory:

 cpanm -L bundle --quiet --notest --self-contained --with-recommends --installdeps .

Afterward, all the modules are in bundle/lib/perl5. Which is almost exactly what I want. Is there an incantation to feed cpanm — or an environment variable to set — to get cpanm to tell the installer to put the files in bundle/lib, instead? I assume I'd need to do something to convince ExtUtils::MakeMaker and Module::Build to append a different value to the install_base, but I haven't been able to figure out how.


Solution

  • Trolling through the Module::Build source, it looks like it's not possible to install modules without the perl5 part of the directory — at least not when using install_base (which cpanm's --self-contained implies). Judging from the comment, it appears that the decision was made to be consistent about always installing in lib/perl5 when using install_base, so as to keep things as predictable as possible. It looks like MakeMaker has it hard-coded, too.