Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Installed CPAN Modules in Problematic Location

by Likeless (Acolyte)
on Nov 10, 2015 at 17:01 UTC ( #1147375=perlquestion: print w/replies, xml ) Need Help??
Likeless has asked for the wisdom of the Perl Monks concerning the following question:

I am using CentOS 7 and seting up a new server.

Whilst logged in as root, I have installed multiple perl modules through CPAN. Unfortunately, they seem to have installed inside root's home directory. I didn't notice this until all the modules were installed, but most of them have locations like this now:

/root/perl5/lib/perl5/5.16.3/x86_64-linux-thread-multi /root/perl5/lib/perl5/5.16.3 /root/perl5/lib/perl5/x86_64-linux-thread-multi /root/perl5/lib/perl5 /usr/local/lib64/perl5

This means that, for users other than root, these modules essentially do not exist, as the permissions lock them out of that directory.

I know I could solve this by giving all users read access to /root, but I'd rather not.

So, I have a few specific questions to ask:

  • What did I do wrong? Did I skip an option in CPAN the first time it ran? (CPAN config is pasted below)
  • What is the best way to clean this up? I presume I need to uninstall the modules, change my config, and then reinstall them? Experienced advice is appreciated.
  • What is the ideal general installation directory for CentOS 7? Where do I want to move them to? I assumed CPAN would put them in an ideal default location.

All advice gratefully received.

cat $CPAN::Config = { 'applypatch' => q[], 'auto_commit' => q[1], 'build_cache' => q[100], 'build_dir' => q[/root/.cpan/build], 'build_dir_reuse' => q[0], 'build_requires_install_policy' => q[yes], 'bzip2' => q[], 'cache_metadata' => q[1], 'check_sigs' => q[0], 'colorize_output' => q[0], 'commandnumber_in_prompt' => q[1], 'connect_to_internet_ok' => q[1], 'cpan_home' => q[/root/.cpan], 'ftp_passive' => q[1], 'ftp_proxy' => q[], 'getcwd' => q[cwd], 'gpg' => q[/bin/gpg], 'gzip' => q[/bin/gzip], 'halt_on_failure' => q[0], 'histfile' => q[/root/.cpan/histfile], 'histsize' => q[100], 'http_proxy' => q[], 'inactivity_timeout' => q[0], 'index_expire' => q[1], 'inhibit_startup_message' => q[0], 'keep_source_where' => q[/root/.cpan/sources], 'load_module_verbosity' => q[none], 'make' => q[/bin/make], 'make_arg' => q[], 'make_install_arg' => q[], 'make_install_make_command' => q[/bin/make], 'makepl_arg' => q[], 'mbuild_arg' => q[], 'mbuild_install_arg' => q[], 'mbuild_install_build_command' => q[./Build], 'mbuildpl_arg' => q[], 'no_proxy' => q[], 'pager' => q[/bin/less], 'patch' => q[/bin/patch], 'perl5lib_verbosity' => q[none], 'prefer_external_tar' => q[1], 'prefer_installer' => q[MB], 'prefs_dir' => q[/root/.cpan/prefs], 'prerequisites_policy' => q[follow], 'scan_cache' => q[atstart], 'shell' => q[/bin/bash], 'show_unparsable_versions' => q[0], 'show_upload_date' => q[0], 'show_zero_versions' => q[0], 'tar' => q[/bin/tar], 'tar_verbosity' => q[none], 'term_is_latin' => q[1], 'term_ornaments' => q[1], 'test_report' => q[0], 'trust_test_report_history' => q[0], 'unzip' => q[], 'urllist' => [q[], q[http://ww], q[http://cpan.mirrors]], 'use_sqlite' => q[0], 'version_timeout' => q[15], 'wget' => q[/bin/wget], 'yaml_load_code' => q[0], 'yaml_module' => q[YAML], }; 1; __END__

Replies are listed 'Best First'.
Re: Installed CPAN Modules in Problematic Location
by tonto (Friar) on Nov 10, 2015 at 18:38 UTC

    I have a Centos 7 VPS (OpenVZ) and a Centos 7 VM (in VMWare Workstation), both 64 bit. I checked @INC on both and got identical results:

    @INC: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .

    I use cpanminus to install modules. You can find that on the How to Install CPAN modules page. It doesn't require any setup.

    Before you start deleting things, I think you should check @INC. You can do that by entering "perl -V" in a terminal. If that root location is in @INC, I think you'll have to remove it from there before you delete anything.

    Of course, Centos recommends that you use their repos to install modules but you've probably installed your own perl so you don't want to do that?

    I hope this is at least a little help.

      The CPAN configuration program now defaults the installation location to local (lib::local or such. Choose the second option (sudo) for a system-wide install.
        On a new Centos 7 machine, I found that "yum install cpan" caused some lines to be added to ~root/.bashrc which set the Perl environment variables to use a local installation path, rather than the system-wide path. I removed those lines, removed ~root/perl5 and ~root/.cpan, logged out, and logged back in. Then I ran through the whole cpan setup again, and it worked fine, using the system-wide locations for Perl module installation.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1147375]
Front-paged by Corion
[1nickt]: chacham I have wanted to, and dones so, and so stated in a reply, and been roundly downvoted 2-1. (I assume for attempting to censor.)
[1nickt]: pryrt yes, I see. There is no way to differentiate without forcing to a string and all sort of weird stuff. It is enough. User 42 can get creative if s/he wishes.

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2017-05-24 20:48 GMT
Find Nodes?
    Voting Booth?