Only1KW has asked for the wisdom of the Perl Monks concerning the following question:

I've spent hours trying to figure this out with no luck, so I have to ask: How do I get CPAN to create and use a global configuration file for all users instead of creating one at ~/.cpan/CPAN/MyConfig.pm for each user? I'd really like to have only one configuration file so other authorized users aren't installing packages and source to the four corners of the hard drives.

I've poured over perldocs, but can't find any relevant information. The best I could find was that the FirstTime module documentation says "The init routine asks a few questions and writes a CPAN/Config.pm or CPAN/MyConfig.pm file (depending on what it is currently using)" but what does it mean by "currently using"? I've tried deleting my ~/.cpan directory and restarting cpan (and NOT configuring as much as possible automatically). I get the following from the script:

The following questions are intended to help you with the configuratio +n. The CPAN module needs a directory of its own to cache important in +dex files and maybe keep a temporary mirror of CPAN files. This may +be a site-wide or a personal directory. I see you already have a directory ~/.cpan Shall we use it as the general CPAN build and cache directory? <cpan_home> CPAN build and cache directory? [~/.cpan]

Well, the script automatically first creates a new ~/.cpan directory, so of course I "already have a directory." I've modified the "CPAN build and cache directory" to the global location, but the script still only creates MyConfig.pm in ~/.cpan.

Even if I wanted to modify a global Config.pm file, which preexisting one would I use, or if I'm supposed to create a new one, where does it go?

../lib/5.14.1/aix-thread-multi-64all/Config.pm ../lib/5.14.1/aix-thread-multi-64all/Encode/Config.pm ../lib/5.14.1/Net/Config.pm ../lib/5.14.1/ExtUtils/MakeMaker/Config.pm ../lib/5.14.1/CPANPLUS/Config.pm ../lib/5.14.1/Log/Message/Config.pm ../lib/5.14.1/Module/Build/Config.pm ../src/perl-5.14.1/lib/Net/Config.pm ../src/perl-5.14.1/lib/ExtUtils/MakeMaker/Config.pm ../src/perl-5.14.1/lib/Config.pm ../src/perl-5.14.1/lib/CPANPLUS/Config.pm ../src/perl-5.14.1/lib/Log/Message/Config.pm ../src/perl-5.14.1/lib/Module/Build/Config.pm ../src/perl-5.14.1/lib/Encode/Config.pm ../src/perl-5.14.1/cpan/libnet/Net/Config.pm ../src/perl-5.14.1/cpan/Encode/lib/Encode/Config.pm ../src/perl-5.14.1/cpan/Log-Message/lib/Log/Message/Config.pm ../src/perl-5.14.1/cpan/Module-Build/lib/Module/Build/Config.pm ../src/perl-5.14.1/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker/Conf +ig.pm ../src/perl-5.14.1/cpan/ExtUtils-MakeMaker/t/testdata/reallylongdirect +oryname/arch2/Config.pm ../src/perl-5.14.1/cpan/ExtUtils-MakeMaker/t/testdata/reallylongdirect +oryname/arch1/Config.pm ../src/perl-5.14.1/cpan/CPANPLUS/lib/CPANPLUS/Config.pm

Replies are listed 'Best First'.
Re: Using CPAN Config.pm instead of MyConfig.pm
by choroba (Cardinal) on Jul 22, 2011 at 20:58 UTC
    I'd really like to have only one configuration file so other authorized users aren't installing packages and source to the four corners of the hard drives.
    In MyConfig.pm, you can define cpan_home. I am not sure if assigning something global to this key would solve your issue.

    Even if everyone uses the same configuration by default, they can nevertheless call cpan -j another_config or even, horrors, install the downloaded modules manually.

      I understand that other users could easily get around the default paths set in a global config file, and accept that risk. My bigger concern is users unintentionally placing modules in locations not covered by @INC rather than users that are intentionally being devious. As I said, only a few users will have the necessary permissions to install modules in a global location anyways.

Re: Using CPAN Config.pm instead of MyConfig.pm
by jpl (Monk) on Jul 23, 2011 at 20:49 UTC
    There's a similar thread at CPAN shared by multiple users. It's a decent start, but there is a problem if you want shared groups, and group ownership propagation on directories is based on the set-groupid bit in the parent directory (rather than on a file-system-wide mount option). The set-groupid-bit gets cleared by CPAN installs, so group ownership of sub-directories can disappear. I filed a bug report, but haven't heard anything. I also wrote some scripts to coerce the ownership and permissions back into something more reasonable. I could post them, if there's interest.