in reply to Re: CPANPLUS custom configurations
in thread CPANPLUS custom configurations

A configuration file is any module with a name starting with "CPANPLUS/Config/", relative to the current base directory (by default: $home/.cpanplus on a linux system) or any folder in @INC.

Thanks a lot, works.

But what is interesting (strace-d), if any such module is found in @INC, the same module is also being loaded from $HOME/.cpanplus first, so the one found in @INC has no effect. A bug? A feature?

What is also important, make sure that the package in which the configuration is defined matches the filename, or the configuration will be ignored (possibly with some errors on the console). Seems normal, but may be missed when copying the saved User.pm file to e.g. SomeLocal.pm without changing the package name.

So to sum up with some code, I use custom cpanp configuration for local dir "installations" by starting it in a directory having CPANPLUS/Config/SomeLocal.pm:

package CPANPLUS::Config::SomeLocal; use warnings; use strict; use Cwd; sub setup { my $conf = shift; my $d = getcwd; $conf->set_conf( base => "$d/.cpanplus" ); $conf->set_conf( buildflags => "install_base=$d/perl" ); $conf->set_conf( makemakerflags => "INSTALL_BASE=$d/perl" ); return 1; } 1;

Replies are listed 'Best First'.
Re^3: CPANPLUS custom configurations
by ig (Vicar) on May 09, 2009 at 03:45 UTC
    But what is interesting (strace-d), if any such module is found in @INC, the same module is also being loaded from $HOME/.cpanplus first, so the one found in @INC has no effect. A bug? A feature?

    The configuration modules are loaded using require. Thus a given module will only be loaded once, even if multiple instances occur in the various directories in @INC, and the first one found in @INC will be loaded. This is standard behavior for require.

    While loading configuration modules, CPANPLUS localizes @INC and prepends the user's cpanplus library directory to @INC (on unix systems this is ~/.cpanplus/lib with ~ expanded to the current user's home directory). Thus, as you observed, configuration is loaded preferentially from this directory in the case that a module of the same name also exists somewhere else.

    It seems quite deliberate, so I guess it's a feature.