3

Running the following command returns several paths:

perl -e 'print join("\n",@INC,"")'

Every path has modules installed within. I would want to install modules, as root, into the following directory:

/usr/local/share/perl5

What commands would I run to find where cpan,as root, currently installs modules? How would I alter it if it is not the path shown above?

tadman
  • 208,517
  • 23
  • 234
  • 262
PaulM
  • 345
  • 2
  • 11
  • 1
    I would probably just use [local::lib](https://metacpan.org/pod/local::lib) (or at least check how it does it). – melpomene Aug 16 '18 at 21:09

2 Answers2

3

Here's how I have configured cpan to put all new modules in a specific directory:

o conf makepl_arg 'PREFIX=/usr/local/share/perl5 INSTALLMAN3DIR=/usr/local/share/perl5/man/man3'
o conf mbuild_arg '--install_base /usr/local/share/perl5'
o conf mbuild_install_arg '--install_base /usr/local/share/perl5'
o conf mbuildpl_arg '--install-base /usr/local/share/perl5'
[o conf commit]

The first line addresses modules that use ExtUtils::MakeMaker and the next three lines are for modules that use Module::Build.

mob
  • 117,087
  • 18
  • 149
  • 283
  • How would I issue those command to see where they point to currently? – PaulM Aug 16 '18 at 16:50
  • `o conf` (all) or `o conf {name}` will show the current value, which is probably blank. Use `perl -V:'.*inst.*'` for the dirs `perl` will use by default – ikegami Aug 16 '18 at 17:35
  • @ikegami sitelib='/usr/local/share/perl5';installsitelib='/usr/local/share/perl5'; makepl_arg [INSTALLDIRS=site] mbuildpl_arg [--installdirs site] Is this pointing all to /usr/local/share/perl5? – PaulM Aug 16 '18 at 17:57
  • The above did not quite work as expected for me. I noticed that when I installed a module from CPAN, it was installing it in /usr/local/share/perl/5.30.3. But I'm worried that when Perl gets updated via apt that this module will get left behind. So I figured, maybe I should install modules in somewhere a bit longer lasting for example /usr/share/perl5. So I changed the PREFIX and install_base to that in the above. But when I installed Mail::DMARC, it installed it in /usr/share/perl5/lib/perl5/Mail/DMARC! What would I have to set these vars to to install in /usr/share/perl5? – Michael Grant Nov 14 '20 at 20:51
0

You can also do this quite easily via App::cpm.

 $ cpm install -L my-random-folder Open::This

 DONE install Path-Tiny-0.108 (using prebuilt)
 DONE install Try-Tiny-0.30 (using prebuilt)
 DONE install Module-Build-0.4224 (using prebuilt)
 DONE install Module-Runtime-0.016 (using prebuilt)
 DONE install Open-This-0.000008 (using prebuilt)
 5 distributions installed.

 $ tree my-random-folder
 my-random-folder
 ├── bin
 │   ├── config_data
 │   └── ot
 └── lib
      └── perl5
           ├── 5.26.1
           │   └── darwin-2level
           ├── Module
           │   ├── Build
           │   │   ├── API.pod
           │   │   ├── Authoring.pod
           │   │   ├── Base.pm
           │   │   ├── Bundling.pod
           │   │   ├── Compat.pm
           │   │   ├── Config.pm
           │   │   ├── ConfigData.pm
           │   │   ├── Cookbook.pm
           │   │   ├── Dumper.pm
           │   │   ├── Notes.pm
           │   │   ├── PPMMaker.pm
           │   │   ├── Platform
           │   │   │   ├── Default.pm
           │   │   │   ├── MacOS.pm
           │   │   │   ├── Unix.pm
           │   │   │   ├── VMS.pm
           │   │   │   ├── VOS.pm
           │   │   │   ├── Windows.pm
           │   │   │   ├── aix.pm
           │   │   │   ├── cygwin.pm
           │   │   │   ├── darwin.pm
           │   │   │   └── os2.pm
           │   │   └── PodParser.pm
           │   ├── Build.pm
           │   └── Runtime.pm
           ├── Open
           │   └── This.pm
           ├── Path
           │   └── Tiny.pm
           ├── Try
           │   └── Tiny.pm
           └── darwin-2level
                └── auto
                     ├── Module
                     │   ├── Build
                     │   └── Runtime
                     ├── Open
                     │   └── This
                     ├── Path
                     │   └── Tiny
                     └── Try
                          └── Tiny
oalders
  • 5,239
  • 2
  • 23
  • 34