Can't locate local/lib.pm in @INC at /usr/share/perl/5.14/CPAN/FirstTime.pm

42,146

Solution 1

You're missing local::lib, which is what you told CPAN shell to do.

You can install it like so:

sudo apt-get install liblocal-lib-perl

You might be able to start over by rm -rf-ing your ~/.cpan directory. AT YOUR OWN RISK

However, I would recommend trying cpanminus instead of the old CPAN shell.

sudo apt-get install cpanminus

Solution 2

Several New OS's force (like Redhat 7) force to check presence of local::lib in the perl version, actually its a good thing this enables to users to use CPAN and add,experiment and enjoy new modules to be used with the perl without waiting for sitewide installation (like a root user). By default local::lib looks for $HOME/perl5 dir where the user's local or downloaded modules are located. If you see this problem then you have to do following

  1. sudo su - whatever_user_owns_perl
  2. whatever_perl_install_path/cpan install local::lib

Solution 3

The local namespace was for your own personal modules and wouldn't be found in CPAN. This is something relatively new. At many sites, you might need CPAN modules not in the current version of Perl, or you need a newer version of a particular module. However, you don't have write access to the standard location where CPAN modules are installed.

What this is doing is installing these modules under the $HOME/perl5/lib/local directory where you'll be able to access them. You would also need to setup a PERL5LIB environment variable (usually in your startup scripts), so Perl will check this directory when locating these modules.

If you have sudo privileges, use that to install CPAN modules rather than trying this. The following will install the Foo::Bar module into the standard module directory for you (and do any configuration as necessary):

$ sudo cpan install Foo::Bar

If CPAN needs to be configured, it will do that first.

There are complete directions on doing the local::lib install for modules on MetaCPAN. They're pretty clear.

Share:
42,146
JJD
Author by

JJD

Android, Kotlin, Java, Git, Python, Ruby, Ruby on Rails, JavaScript, MacOS, Ubuntu #SOreadytohelp http://stackoverflow.com/10m

Updated on March 07, 2020

Comments

  • JJD
    JJD about 4 years

    I am trying to use Perl the first time on my system which is Ubuntu 12.04. I have Perl v.5.14.2 installed.
    I looked up how to install Perl modules, so I started as follows:

    $ perl -MCPAN -e shell
    

    The wizard started configuring the environment as can be seen here: http://pastebin.com/5hn8vkb5
    Though, it stopped in the middle with the following error message:

    ...
    
    Checksum for /home/john/.cpan/sources/authors/id/A/AP/APEIRON/local-lib-1.008009.tar.gz ok
    ---- Unsatisfied dependencies detected during ----
    ----     APEIRON/local-lib-1.008009.tar.gz    ----
        ExtUtils::MakeMaker [build_requires]
    Running make test
      Make had some problems, won't test
      Delayed until after prerequisites
    Running make install
      Make had some problems, won't install
      Delayed until after prerequisites
    
    Can't locate local/lib.pm in @INC (@INC contains:
        /home/john/perl5/lib/perl5
        /etc/perl
        /usr/local/lib/perl/5.14.2
        /usr/local/share/perl/5.14.2
        /usr/lib/perl5
        /usr/share/perl5
        /usr/lib/perl/5.14
        /usr/share/perl/5.14
        /usr/local/lib/site_perl
        /home/john/Desktop)
    at /usr/share/perl/5.14/CPAN/FirstTime.pm line 1300.
    

    What can I do to setup the Perl environment correctly on my Ubuntu installation?


    After interrupting the wizard and restarting it again, there is no error message anymore. How can I start the wizard again so I can choose here:

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

  • JJD
    JJD almost 11 years
    Thank you for the detailed explainations. I noticed that modules are installed locally but haven't been accessible in the PATH for Perl. Therefore, I tried --sudo. Thank you for the link, too.
  • Charles Duffy
    Charles Duffy over 10 years
    Sadly, neither liblocal-lib-perl or cpanminus is packaged in Ubuntu 12.04.
  • chrsblck
    chrsblck over 10 years
    @CharlesDuffy - output from Ubuntu 12.04.3 LTS: $ apt-cache search liblocal-lib-perl liblocal-lib-perl - module to use a local path for Perl modules and $ apt-cache search cpanminus cpanminus - script to get, unpack, build and install modules from CPAN
  • Charles Duffy
    Charles Duffy over 10 years
    ...not so much, by contrast, on the official ubuntu:12.04 docker image.
  • Charles Duffy
    Charles Duffy over 10 years
    Ahh -- said docker image only contains main. I'm guessing these are elsewhere (universe or such)?
  • Will Bickford
    Will Bickford over 10 years
    liblocal-lib-perl is definitely packaged for Ubuntu LTS 12.04.3. I just installed it.
  • IgorGanapolsky
    IgorGanapolsky over 7 years
    I am always getting an error: debconf: Perl may be unconfigured (Can't locate strict.pm in @INC (you may need to install the strict module) (@INC contains: /etc/perl
  • Tal
    Tal about 4 years
    " perl_install_path/cpan install local::lib " this work for me