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

NOTE: I'm no longer looking for an answer to this specific question, because I'm using plenv instead. However, I would still like to know whether (and why) CPAN checks the versions of modules installed on @INC, when it should just be managing its own directory of modules.

Many modules fail when I try to install them in CPAN, including CPAN itself. This may be because my CPAN thinks it has lower versions of many modules. For example,

cpan[12]> upgrade JSON::PP Package namespace installed latest in CPAN file JSON::PP 2.24000 2.27300 MAKAMAKA/JSON-PP-2.2730 +0.tar.gz Running install for module 'JSON::PP' Running make for M/MA/MAKAMAKA/JSON-PP-2.27300.tar.gz Has already been unwrapped into directory /home/me/.cpan/build/JSON- +PP-2.27300-dwlFCV Has already been made Running make test Has already been tested successfully Running make install Already done cpan[13]> r JSON::PP Package namespace installed latest in CPAN file JSON::PP 2.24000 2.27300 MAKAMAKA/JSON-PP-2.2730 +0.tar.gz cpan[14]> quit Lockfile removed. ]$ rm -rf ~/.cpan/build/JSON-PP-2.27300-dwlFCV ]$ rm -rf ~/perl5/lib/perl5/JSON ]$ rm -rf ~/.cpan/sources/authors/id/M/MA/MAKAMAKA ]$ cpan cpan[1]> r JSON::PP CPAN: Storable loaded ok (v2.20) Going to read '/home/me/.cpan/Metadata' Database was generated on Fri, 29 May 2015 14:17:02 GMT Package namespace installed latest in CPAN file JSON::PP 2.24000 2.27300 MAKAMAKA/JSON-PP-2.2730 +0.tar.gz cpan[2]> force install JSON::PP ... Result: PASS MAKAMAKA/JSON-PP-2.27300.tar.gz /usr/bin/make test -- OK Running make install Prepending /home/me/.cpan/build/JSON-PP-2.27300-ZHQLK0/blib/arch /home +/me/.cpan/build/JSON-PP-2.27300-ZHQLK0/blib/lib to PERL5LIB for 'inst +all' Manifying blib/man1/json_pp.1 Appending installation info to /home/me/perl5/lib/perl5/x86_64-linux-t +hread-multi/perllocal.pod Installing /home/me/perl5/lib/perl5/JSON/PP.pm Installing /home/me/perl5/lib/perl5/JSON/PP/Boolean.pm MAKAMAKA/JSON-PP-2.27300.tar.gz /usr/bin/make install -j17 -- OK cpan[2]> r JSON::PP Package namespace installed latest in CPAN file JSON::PP 2.24000 2.27300 MAKAMAKA/JSON-PP-2.2730 +0.tar.gz
Why does it keep reporting version 2.24, even after I've removed the module and after I've installed 2.273 again?

Replies are listed 'Best First'.
Re: CPAN frequently reports older module version
by hippo (Archbishop) on May 29, 2015 at 15:27 UTC

    Perhaps that is because it has been installed in some other directory in @INC? Perhaps via a package manager? What happens if you try to locate JSON/PP.pm?

      There are many copies of JSON/PP.pm on the system, but my PERL5LIB is unset, so I think nothing is on @INC. I would think CPAN would not look at @INC anyway. Shouldn't it use only its local install directory? Surely allowing the same CPAN to be used with different library paths would lead to disaster!
        my PERL5LIB is unset, so I think nothing is on @INC

        Just dump @INC, so you don't have to guess:

        perl -E 'say for @INC'

        You don't use more than one perl version, do you?

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
        There are many copies of JSON/PP.pm on the system

        Is one of them version 2.24 by any chance?

Re: CPAN frequently reports older module version
by jeffa (Bishop) on May 29, 2015 at 22:52 UTC

    This is why i use perlbrew on every system i develop on now. Not only does it allow you to control what versionS of Perl you want to work with, it also provides a ready-to-use cpanm client which is a vast improvement over the old interactive CPAN client. cpanm does a pretty good job of removing CPAN modules too.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
Re: CPAN frequently reports older module version
by FreeBeerReekingMonk (Deacon) on May 29, 2015 at 21:17 UTC

    Try to also upgrade your cpan. Type cpan, then inside it type "install CPAN". maybe you do need a higher cpan version... it also rechecks unmet dependencies and has fixed some weird cpan problems for me in the past...

      "Many modules fail when I try to install them in CPAN, including CPAN itself."

        If your repository is in ~/.cpan then why not move the directory to ~/.cpan.old and try to download again?