miyagawa / cpanminus

cpanminus - get, unpack, build and install modules from CPAN
http://cpanmin.us
746 stars 213 forks source link

cpanm fails to upgrade a module #658

Closed rlauer6 closed 1 year ago

rlauer6 commented 1 year ago

Trying to install a new version of a module appears to succeed, however the module version remains the same.

cpanm (App::cpanminus) version 1.7046 (/usr/local/bin/cpanm)
perl version 5.016003 (/usr/bin/perl)

  %Config:
    archname=x86_64-linux-thread-multi
    installsitelib=/usr/local/share/perl5
    installsitebin=/usr/local/bin
    installman1dir=/usr/share/man/man1
    installman3dir=/usr/share/man/man3
    sitearchexp=/usr/local/lib64/perl5
    sitelibexp=/usr/local/share/perl5
    vendorarch=/usr/lib64/perl5/vendor_perl
    vendorlibexp=/usr/share/perl5/vendor_perl
    archlibexp=/usr/lib64/perl5
    privlibexp=/usr/share/perl5
  %ENV:
  @INC:
    FatPacked::19496408=HASH(0x1297dd8)
    /usr/local/lib64/perl5
    /usr/local/share/perl5
    /usr/lib64/perl5/vendor_perl
    /usr/share/perl5/vendor_perl
    /usr/lib64/perl5
    /usr/share/perl5
    .
bash-4.2# perl -MPod::Parser -e 'print $Pod::Parser::VERSION;'
bash-4.2# cpanm -n Pod::Parser~1.65
--> Working on Pod::Parser
Fetching http://www.cpan.org/authors/id/M/MA/MAREKR/Pod-Parser-1.65.tar.gz ... OK
Configuring Pod-Parser-1.65 ... OK
Building Pod-Parser-1.65 ... OK
Successfully installed Pod-Parser-1.65 (upgraded from 1.61)
1 distribution installed
bash-4.2# perl -MPod::Parser -e 'print $Pod::Parser::VERSION;'
1.61bash-4.2# 
skaji commented 1 year ago

Pod::Parser 1.61 is in vendorlib /usr/share/perl5/vendor_perl.

cpanm installs Pod::Parser 1.65 into perllib/corelib /usr/share/perl5 because Pod::Parser 1.65 itself specifies INSTALLDIRS is perl; see https://metacpan.org/release/MAREKR/Pod-Parser-1.65/source/Makefile.PL#L73

This is an issue for Pod::Parser 1.65, not for cpanm.

rlauer6 commented 1 year ago

Thank you...

If I specifically tell cpanm to install to /usr/local (siteprefix) which if I understand @INC order, I should not be seeing an older version of Pod::Parser?

   Built under linux
  Compiled at Feb 17 2021 20:26:47
  @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
    .
bash-4.2# cpanm -v -l /usr/local Pod::Parser
cpanm (App::cpanminus) 1.7046 on perl 5.016003 built for x86_64-linux-thread-multi
Work directory is /root/.cpanm/work/1676905193.6795
You have make /usr/bin/make
You have LWP 6.67
Falling back to Archive::Tar 1.92
Searching Pod::Parser () on cpanmetadb ...
Pod::Parser is up to date. (1.65)
bash-4.2# perl -MPod::Parser -e 'print $Pod::Parser::VERSION;'
1.61bash-4.2#
skaji commented 1 year ago

It would be easier to patch Makefile.PL by yourself.

❯ wget https://cpan.metacpan.org/authors/id/M/MA/MAREKR/Pod-Parser-1.65.tar.gz
❯ tar xf Pod-Parser-1.65.tar.gz
❯ cd Pod-Parser-1.65

# comment out INSTALLDIRS stuff
❯ perl -i -pe 's/^\s*INSTALLDIRS/# INSTALLDIRS/' Makefile.PL

❯ perl Makefile.PL
❯ make
❯ make install

❯ ls -al /usr/local/share/perl5/Pod/Parser.pm
❯ perl -MPod::Parser\ 99999999
Pod::Parser version 99999999 required--this is only version 1.65.
BEGIN failed--compilation aborted.
rlauer6 commented 1 year ago

Thanks again...and I'm not even sure why I want to upgrade this module 1.61 seems to work fine - however is it true that this:

INSTALLDIRS => ($] >= 5.006 ? 'perl' : 'site'),

so is the bug that this statement should have been:

INSTALLDIRS => ($] >= 5.006 ? 'perl' : 'site'),

Oddly the original statement seems to read "install this in perl because starting 5.06 the module is in core". if the original statement is correct wouldn't that imply you couldn't upgrade any module that is in core? Looking at something like

List::Util I see:INSTALLDIRS => ($] < 5.011 ? q[perl] : q[site]),'

which also now part of core...but allows upgrade

miyagawa commented 1 year ago

perl 5.12 changed the order of @INC so that core modules can be upgraded in site while retaining the original version in perl. The code in List::Util is the correct one for the current core modules. Pod::Parser isn't even a core module anymore in perl 5.32 or later, and I don't understand why they keep the line there.

https://perldoc.perl.org/perl5120delta#@INC-reorganization

rlauer6 commented 1 year ago

Thank you again! Now it makes sense why List::Util installs to site now...so I would consider Pod::Parser installation order a bug