Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Broken cpan

by halfcountplus (Hermit)
on Apr 22, 2014 at 15:14 UTC ( [id://1083189]=perlquestion: print w/replies, xml ) Need Help??

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

My cpan install has broken, perhaps because of some recent upgrade, or perhaps because I killed it in the middle of an operation when I realized I had typed the wrong parameters.

Catching error: "Can't locate object method \"requirements_for_module\ +" via package \"CPAN::Meta::Requirements\" at /usr/share/perl5/CPAN/D +istribution.pm line 2802.\cJ" at /usr/share/perl5/CPAN.pm line 392. CPAN::shell() called at /usr/share/perl5/App/Cpan.pm line 339 App::Cpan::_process_options("App::Cpan") called at /usr/share/ +perl5/App/Cpan.pm line 422 App::Cpan::run("App::Cpan") called at /bin/cpan line 12

This message is the same regardless of the operation. If I try an install whatever and then force install whatever I get told "whatever" has already been unwrapped into a directory; make in the cpan shell fails with the same error, but I can enter the directory manually and run perl Makefile.PL, make, etc.

cpan --version is 1.61 under perl 5.18.2.

Replies are listed 'Best First'.
Re: Broken cpan
by tobyink (Canon) on Apr 22, 2014 at 15:46 UTC

    The version number 1.61 is not especially helpful. That's the version number of the App::Cpan module, but there have been several releases of the CPAN distribution that include the same version of the App::Cpan module. (The CPAN distribution is quite annoying in that each of its internal modules has its own completely independent version numbering system. With most multi-module distributions, people tend to keep the version numbers for each module synchronized.) You can find out what version of the CPAN distribution you have using:

    perl -MCPAN -E'say $CPAN::VERSION'

    But anyway, it looks like your CPAN version is new enough for you to need a more recent version of CPAN::Meta::Requirements than the one you have. You can find out what version of CPAN::Meta::Requirements you have like this:

    perl -MCPAN::Meta::Requirements -E'say $CPAN::Meta::Requirements::VERS +ION'

    I'd recommend installing an up to date copy of CPAN::Meta::Requirements. But how to do that if your CPAN client is broken?

    Download the archive, then run:

    tar zxfv CPAN-Meta-Requirements-2.125.tar.gz cd CPAN-Meta-Requirements-2.125 perl Makefile.PL make all make test && sudo make install

    Also, you should clear your build directory. This will solve the "unwrapped" problem.

    rm -fr ~/.cpan/build/

    Hopefully that will fix everything.

    use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

      This may well have fixed it (but see my comment to marto's answer). I'm suspicious because the version difference was only from 2.120351 to 2.125 -- but OTOH, this was one of the modules with overlap in the two `/usr/local` directories; 2.125 had been installed (presumably by a previous upgrade) but the older one was taking precedence.

        If I were you, what I'd do, is now that the system Perl is in a reasonable state; use that to install App::perlbrew; use perlbrew to install a fresh copy of Perl in my home directory; and use that fresh copy of Perl for any serious work.

        There is a popular school of thought that you should touch the version of Perl that was pre-installed with your system as little as possible, because upgrading modules might break your system. (Lots of Linux distributions' admin scripts, package managers, etc are written in Perl.)

        use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
      I hit the same breakage but was able to 'look CPAN::Meta::Requirements' and then 'perl Makefile.PL; make; make install' successfully, without having to download manually.
        I ran into this as well on an (otherwise) pretty uncomplicated install of CentOS 6.5, and your solution worked for me as well. But what is the fundamental problem? Why does CPAN insist on hosing itself in this way?
        this solution worked great for me.
        That worked for me. Thanks!
Re: Broken cpan
by marto (Cardinal) on Apr 22, 2014 at 15:20 UTC

    Try this, exit the cpan shell and rename your .cpan directory to .cpan.backup, then try again.

      Didn't work, but one thing I noticed when doing this is that I have a `/usr/local/lib64/perl5` and a `/usr/local/share/perl5`, and there is (was) some overlap. One or the other was probably created by me as an option when running cpan for the first time, although I could not find a reference to it in the old ".cpan.bk".

      So I merged the two and left a symlink, then tried tobyink's suggestion. Not sure which of those did the trick, but it now works.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1083189]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2024-03-28 19:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found