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

I am unable to install any modules with cpan. I even upgraded to the latest perl and the latest cpan, but that didn't help. Here is where I am at now:

----------- $ which perl /usr/local/bin/perl $ perl -v This is perl, v5.10.1 (*) built for darwin-2level Copyright 1987-2009, Larry Wall <snip> $ which cpan /usr/local/bin/cpan $ cpan -v /usr/local/bin/cpan script version 1.9, CPAN.pm version 1.9402 $ sudo find / -type f -name CPAN.pm /System/Library/Perl/5.8.6/CPAN.pm /Users/me/.cpan/Bundle/CPAN.pm /Users/me/my_tar_extractions/perl-5.10.1/lib/CPAN.pm /usr/local/lib/perl5/5.10.1/CPAN.pm $ sudo perl -MCPAN -e shell Password: Terminal does not support AddHistory. cpan shell -- CPAN exploration and modules installation (v1.9402) Enter 'h' for help. cpan[1]> install FileUtils::More CPAN: Storable loaded ok (v2.20) Going to read '/Users/me/.cpan/Metadata' Database was generated on Sun, 01 Nov 2009 22:27:00 GMT CPAN: Time::HiRes loaded ok (v1.9719) LWP not available Trying with "/usr/local/bin/curl -L -f -s -S --netrc-optional" to get "http://mirrors.cpan.org/showmirror.cgi?name=xmission.com/authors/ +01mailrc.txt.gz" CPAN: Compress::Zlib loaded ok (v2.02) Error while trying to rename '/Users/me/.cpan/sources/authors/01mailrc +.txt.gz.tmp604' to '/Users/me/.cpan/sources/authors/01mailrc.txt.gz': + No such file or directory LWP not available Trying with "/usr/local/bin/curl -L -f -s -S --netrc-optional" to get "http://mirrors.cpan.org/showmirror.cgi?name=xmission.com/authors/ +01mailrc.txt.gz" Error while trying to rename '/Users/me/.cpan/sources/authors/01mailrc +.txt.gz.tmp604' to '/Users/me/.cpan/sources/authors/01mailrc.txt.gz': + No such file or directoryTerminal does not support GetHistory. Lockfile removed. $ ---------
Can anyone diagnose what the problem is?

Replies are listed 'Best First'.
Re: cpan: unable to install modules
by jethro (Monsignor) on Nov 10, 2009 at 10:32 UTC
    The root problem is probably this: You try to install as root, but the config file cpan uses is in /Users/me/, probably your home dir. That is definitely not how it should be. Either install everything as user (without sudo, first delete .cpan before you do this) or open a root shell and make sure your home is the home of root (echo $HOME)

    In detail your error message might happen if your home dir "/Users/me" is mounted over NFS. In that case root has the rights of user nobody and can't read .cpan if you created that as normal user

    Or curl failed to get the files for some reason and the rename won't work on a file that isn't there. But I would hope that cpan gives better error messages for that condition than 'rename failed'

      Thanks for the response.

      The root problem is probably this: You try to install as root, but the config file cpan uses is in /Users/me/, probably your home dir. That is definitely not how it should be.

      I would like to setup things the way they should be. When you say "that is not how it should be", are you talking about using the sudo command, or the location of the .cpan directory? Does something need to be moved? Re-installed?

      or open a root shell and make sure your home is the home of root (echo $HOME)

      What is a "root shell"? I have full admin privileges.

      I just wanted to add that, as recommended here:

      http://sial.org/howto/perl/life-with-cpan/macosx/

      at some point I did this:

      cpan> o conf makepl_arg "INSTALLBIN=/usr/local/bin INSTALLSCRIPT=/usr/ +local/bin" cpan> o conf commit

      Is that what's causing the problems?

      At that link it also says:

      The first time CPAN is invoked, it will run through a set of questions, such as which CPAN mirror site to use. Following the questions, CPAN may recommend that you install Bundle::CPAN or Bundle::libnet. Avoid installing these bundles!

      Unfortunately, I did follow the cpan instructions and I installed Bundle::CPAN. I think that shows up in my find results that I posted earlier:

      $ sudo find / -type f -name CPAN.pm /System/Library/Perl/5.8.6/CPAN.pm /Users/me/.cpan/Bundle/CPAN.pm <----HERE*** /Users/me/my_tar_extractions/perl-5.10.1/lib/CPAN.pm /usr/local/lib/perl5/5.10.1/CPAN.pm
        Ah, you are on Mac OS X. In that case my advice floats on thin ice as I don't have much knowledge about that system

        A root shell can be opened with "sudo bash" or "sudo sh"

      THIS SOLVED MY PROBLEM ... THANK YOU
Re: cpan: unable to install modules
by Bloodnok (Vicar) on Nov 10, 2009 at 10:32 UTC
    It looks like LWP isn't either installed or on PERL5LIB - clue: ...LWP not available... - easily confirmed by seeing no response to typing perldoc LWP ?

    A user level that continues to overstate my experience :-))

      This is what I get:

      $ perldoc LWP No documentation found for "LWP".

      I don't get it. The latest addition of perl doesn't come with the necessary ingredients to use cpan?

        ...either that, or you've got yourself a broken perl install.

        Do you have LWP installed elsewhere on your system, if so, try adding the path to it [LWP] to your PERL5LIB and running the install again.

        A user level that continues to overstate my experience :-))
      LWP isn't required, curl works, wget works...
        ...curl works, wget works

        Hmmm, one/both of the above is/are self-evidently not true - look at the error returned from the OS during the rename:

        Error while trying to rename '/Users/me/.cpan/sources/authors/01mailrc +.txt.gz.tmp604' to '/Users/me/.cpan/sources/authors/01mailrc.txt.gz': + No such file or directory
        That shouts loudly (to me anyway) that the download of /Users/me/.cpan/sources/authors/01mailrc.txt.gz.tmp604 failed ... quietly.

        A user level that continues to overstate my experience :-))
Re: cpan: unable to install modules
by Your Mother (Archbishop) on Nov 12, 2009 at 03:31 UTC

    This might get you together if you haven't worked it out already (it is *destructive* and assumes you want to only install as root going forward, so only go for it if you're sure). As a plain user, not root-

    rm -rf ~/.cpan

    That will remove all your current CPAN config etc. You can, of course, edit it with o conf or manually in the generated code but starting from scratch is often good. Then (I think this is good, I'm on OS X but I'm not much of a sysadmin)-

    env | grep -i perl

    If any ENV settings turn up in there, empty them. E.g., tcsh: setenv PERL5LIB ""; or bash: export PERL5LIB="". There are a few variables that can turn up in there and mess with installs by pointing at the wrong paths and telling CPAN the wrong things are missing or already installed. Then-

    sudo cpan

    And reinitialize everything. You should be good to go. Just remember to not run the cpan shell as yourself going forward.

Re: cpan: unable to install modules
by Anonymous Monk on Nov 10, 2009 at 23:11 UTC
    Don't use find, use
    perldoc -l CPAN
    or
    perl -MCPAN -le"print $INC{'CPAN.pm'}"
    Also, try using cpanp instead

      Here are my results:

      $ perldoc -l CPAN /usr/local/bin/CPAN $ perl -MCPAN -le"print $INC{'CPAN.pm'}" syntax error at -e line 1, at EOF Execution of -e aborted due to compilation errors.
        See perlrun, you need to quote according to your shell's rules