Elena
Elena

Reputation: 51

how to change configuration of CPAN from local::lib to sudo preference

Hi am new to using perl and installed CPAN using the code: $ perl -MCPAN -e shell and i got the following prompt:

To install modules, you need to configure a local Perl library directory or escalate your privileges. CPAN can help you by bootstrapping the local::lib module or by configuring itself to use 'sudo' (if available). You may also resolve this problem manually if you need to customize your setup.

What approach do you want? (Choose 'local::lib', 'sudo' or 'manual')

I selected local::lib, but i realized that may not be the best for what I want to do and now would like to switch to sudo to build modules not in a local library. I have tried to build libraries but they always get put in a local library.

How would I do this? Thanks

Upvotes: 4

Views: 3765

Answers (4)

G WOLF
G WOLF

Reputation: 41

The solution is only supported for non-root user.

cpan
o conf init 

After the above operation, it will message you "What approach do you want? (Choose 'local::lib', 'sudo' or 'manual')" again when you use cpan.

For root user, it doesn't seem to matter what method you choose. Modules will be installed in path /usr/local/lib/ or /usr/local/share/ by default.

Upvotes: 0

Morten
Morten

Reputation: 1

cpan tells you how to do it, after configuring:

"You can re-run configuration any time with 'o conf init' in the CPAN shell"

Upvotes: 0

To disable local::lib and get the configuration prompt again you must remove:

PATH="/home/.../perl5/bin${PATH:+:${PATH}}";
export PATH;

PERL5LIB="/home/.../perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}";
export PERL5LIB;

PERL_LOCAL_LIB_ROOT="/home/.../perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}";
export PERL_LOCAL_LIB_ROOT;

PERL_MB_OPT="--install_base \"/home/.../perl5\"";
export PERL_MB_OPT;

PERL_MM_OPT="INSTALL_BASE=/home/.../perl5";
export PERL_MM_OPT;

From ~/.bashrc

Upvotes: 1

Orabîg
Orabîg

Reputation: 11992

CPAN may store its configuration and the choice you made in several places, however, you should take a look first at /etc/perl/CPAN/Config.pm and/or $HOME/.cpan/CPAN/MyConfig.pm.

Deleting these file (you may move them as a backup if you're not sure) will reset CPAN to default behavior.

You may also have a look inside these files, find the exact parameter, and remove the corresponding line.

try grep local::lib ~/.cpan/CPAN/MyConfig.pm for example...

Upvotes: 3

Related Questions