使用cpan和cpanm,为什么某些模块已被识别为已更新,但其他模块每次都会重新安装,尽管它是最新的?

时间:2015-02-16 20:06:58

标签: perl cpan

更新:

我发现的一个区别是Data :: Show使用Module :: Build,而Data :: Dumper使用Build文件(使用vimdiff):

vimdiff shows that Data::Dumper uses a Makefile, while Data::Show uses a Build file.


我注意到,使用cpan和cpanm时,如果没有新版本,则不会重新安装某些模块,但每次都会重新安装其他模块。我的PERL5LIB变量中没有任何内容,@INC包含所有正确的路径。我使用perlbrew,但我认为我使用定制的perl有类似的问题:

  %ENV:
    PERLBREW_BASHRC_VERSION="0.73"
    PERLBREW_HOME="/home/username/.perlbrew"
    PERLBREW_MANPATH="/home/username/perl5/perlbrew/perls/perl-5.20.1/man"
    PERLBREW_PATH="/home/username/perl5/perlbrew/bin:/home/user/perl5/perlbrew/perls/perl-5.20.1/bin"
    PERLBREW_PERL="perl-5.20.1"
    PERLBREW_ROOT="/home/username/perl5/perlbrew"
    PERLBREW_VERSION="0.73"
    PERLDEV="/share/data/username/Perl5"
  @INC:
    /home/username/perl5/perlbrew/perls/perl-5.20.1/lib/site_perl/5.20.1/x86_64-linux
    /home/username/perl5/perlbrew/perls/perl-5.20.1/lib/site_perl/5.20.1
    /home/username/perl5/perlbrew/perls/perl-5.20.1/lib/5.20.1/x86_64-linux
    /home/username/perl5/perlbrew/perls/perl-5.20.1/lib/5.20.1
如果没有新版本,

Data::Dumper无法重新安装:

cpanm Data::Dumper
Data::Dumper is up to date. (2.154)

但是,每次都会重新安装Data::Show

$ cpanm Data::Show
--> Working on Data::Show
Fetching http://www.cpan.org/authors/id/D/DC/DCONWAY/Data-Show-0.002002.tar.gz ... OK
Configuring Data-Show-0.002002 ... OK
Building and testing Data-Show-0.002002 ... OK
Successfully installed Data-Show-0.002002
1 distribution installed

$ cpanm Data::Show
--> Working on Data::Show
Fetching http://www.cpan.org/authors/id/D/DC/DCONWAY/Data-Show-0.002002.tar.gz ... OK
Configuring Data-Show-0.002002 ... OK
Building and testing Data-Show-0.002002 ... OK
Successfully installed Data-Show-0.002002
1 distribution installed

cpanm -v Data :: Show

的结果
cpanm (App::cpanminus) 1.7027 on perl 5.020001 built for x86_64-linux
Work directory is /home/username/.cpanm/work/1424150236.20375
You have make /usr/bin/make
You have LWP 6.13
You have /bin/tar: tar (GNU tar) 1.23
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
You have /usr/bin/unzip
Searching Data::Show on cpanmetadb ...
--> Working on Data::Show
Fetching http://www.cpan.org/authors/id/D/DC/DCONWAY/Data-Show-0.002002.tar.gz ... OK
Unpacking Data-Show-0.002002.tar.gz
Data-Show-0.002002/
Data-Show-0.002002/Build.PL
Data-Show-0.002002/Changes
Data-Show-0.002002/lib/
Data-Show-0.002002/Makefile.PL
Data-Show-0.002002/MANIFEST
Data-Show-0.002002/META.yml
Data-Show-0.002002/README
Data-Show-0.002002/t/
Data-Show-0.002002/t/00.load.t
Data-Show-0.002002/t/pod.t
Data-Show-0.002002/t/show.t
Data-Show-0.002002/lib/Data/
Data-Show-0.002002/lib/Data/Show.pm
Entering Data-Show-0.002002
Checking configure dependencies from META.yml
Checking if you have ExtUtils::MakeMaker 0 ... Yes (6.98)
Running Build.PL
Configuring Data-Show-0.002002 ... Module::Build will be removed from the Perl core distribution in the next major release. Please install it from CPAN. It is being used at Build.PL, line 3.
Created MYMETA.yml and MYMETA.json
Creating new 'Build' script for 'Data-Show' version '0.002002'
OK
Checking dependencies from MYMETA.json ...
Checking if you have version 0 ... Yes (0.9909)
Checking if you have Data::Dump 1.17 ... Yes (1.22)
Checking if you have Test::More 0 ... Yes (1.001014)
Building and testing Data-Show-0.002002 ... Module::Build will be removed from the Perl core distribution in the next major release. Please install it from CPAN. It is being used at ./Build, line 40.
Building Data-Show
Module::Build will be removed from the Perl core distribution in the next major release. Please install it from CPAN. It is being used at ./Build, line 40.
t/00.load.t .. 1/1 # Testing Data::Show 0.002002
t/00.load.t .. ok
t/pod.t ...... skipped: Test::Pod 1.14 required for testing POD
t/show.t ..... Smartmatch is experimental at t/show.t line 28.
t/show.t ..... ok
All tests successful.
Files=3, Tests=64,  1 wallclock secs ( 0.06 usr  0.02 sys +  0.12 cusr  0.03 csys =  0.23 CPU)
Result: PASS
Module::Build will be removed from the Perl core distribution in the next major release. Please install it from CPAN. It is being used at ./Build, line 40.
Building Data-Show
OK
Successfully installed Data-Show-0.002002
Installing /home/username/perl5/perlbrew/perls/perl-5.20.1/lib/site_perl/5.20.1/x86_64-linux/.meta/Data-Show-0.002002/install.json
1 distribution installed

非常有趣的是,他们不是都安装到perldoc可以看到的地方:

$ perldoc -l Data::Dump
/home/username/perl5/perlbrew/perls/perl-5.20.1/lib/site_perl/5.20.1/Data/Dump.pm
$ perldoc -l Data::Show
No documentation found for "Data::Show".

1 个答案:

答案 0 :(得分:1)

看起来我的问题是Build.PL文件由于某种原因不起作用。当我看到Data::Show附带Build.PL文件和Makefile.PL时,我尝试使用Makefile手动安装它,然后安装它:

perl Makefile.PL
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Data::Show
Writing MYMETA.yml and MYMETA.json
$ make
cp lib/Data/Show.pm blib/lib/Data/Show.pm
Manifying blib/man3/Data::Show.3
$ make install
Installing /home/username/perl5/perlbrew/perls/perl-5.20.1/lib/site_perl/5.20.1/Data/Show.pm
Installing /home/username/perl5/perlbrew/perls/perl-5.20.1/man/man3/Data::Show.3
Appending installation info to /home/username/perl5/perlbrew/perls/perl-5.20.1/lib/5.20.1/x86_64-linux/perllocal.pod
$ cpanm Data::Show
Data::Show is up to date. (0.002002)