如何将所有 CPAN 模块更新为其最新版本?

How do I update all my CPAN modules to their latest versions?

转载于:https://stackoverflow.com/questions/3727795/how-do-i-update-all-my-cpan-modules-to-their-latest-versions

weixin_41568196
撒拉嘿哟木头 +1 for the modesty, because you asked this on SO, google let me see the answer quicker :) thanks
8 年多之前 回复

5个回答

An alternative method to using upgrade from the default CPAN shell is to use cpanminus and cpan-outdated.

These are so easy & nimble to use that I hardly ever go back to CPAN shell. To upgrade all your modules in one go is:

cpan-outdated -p | cpanm


I recommend you install cpanminus like the docs describe:

curl -L http://cpanmin.us | perl - App::cpanminus

And then install cpan-outdated along with all other CPAN modules using cpanm:

cpanm App::cpanoutdated

BTW: If you are using perlbrew then you will need to repeat this for every Perl you have installed under it.

You can find out more about cpanminus and cpan-outdated at the Github repos here:

csdnceshi65
larry*wei I like this solutions because you can easily run cpan-outdated -p first to see what it is going to do before actually running the upgrades. It isn't clear how to do a dry run with cpan upgrade
2 年多之前 回复
csdnceshi55
~Onlooker Those are old (perl dates from 2006, LWP from 2005). Ideally you need newer version of both. If for some reason you can't do this then I would upgrade LWP version by version until you got cpanm|cpan-outdated working. NB. IMPORTANT - If you are using the CentOS installed Perl then don't use CPAN or CPANMINUS with these! Never mix with OS packages!! Instead use Perlbrew to brew your own perl (and then use cpanminus etc within this).
6 年多之前 回复
csdnceshi78
程序go perl v5.8.8. LWP 5.805. centos 5.10 final
6 年多之前 回复
csdnceshi55
~Onlooker - Need more info... what versions of cpanminus, cpan-outdated, LWP and Perl are you using?
6 年多之前 回复
csdnceshi55
~Onlooker Because it's more "nimble"! The built-in solution (CPAN shell) does not work well in limited memory hence why Miyagawa originally developed cpanminus - metacpan.org/pod/App::cpanminus#Another-CPAN-installer
6 年多之前 回复
csdnceshi78
程序go [root@portal-test bugzilla-4.4.4]# cpan-outdated -p | cpanm Can't locate object method "new" via package "LWP::UserAgent" at /usr/bin/cpan-outdated line 170.
6 年多之前 回复
csdnceshi76
斗士狗 "why using such extra tools" While it's outside the scope of the OP's question, cpanimus DOES solve the problem of CPAN asking you to press Enter and/or type [y]es. Afaict you can not reliably suppress this behavior with vanilla CPAN. This becomes important as soon as any kind of cron or CI server is involved, and/or if you like to be able to start an upgrade with the confidence it won't hang while you're out getting coffee (which in my experience is often the case with vanilla CPAN) See also this answer stackoverflow.com/questions/898782/…
接近 7 年之前 回复
csdnceshi79
python小菜 why using such extra tools while there's a built-in solution (see second answer)?
接近 8 年之前 回复

Try perl -MCPAN -e "upgrade /(.\*)/". It works fine for me.

An easy way to upgrade all Perl packages (CPAN modules) is the following way:

cpan upgrade /(.*)/

cpan will recognize the regular expression like this and will update/upgrade all packages installed.

csdnceshi69
YaoRaoLov For those having problems with this command; Try running cpan shell via cpan, and then run the upgrade /(.*)/ in the cpan shell.
4 年多之前 回复
csdnceshi79
python小菜 this don't work
6 年多之前 回复
csdnceshi63
elliott.david The regex is not even necessary. +
6 年多之前 回复
csdnceshi57
perhaps? Okay, this isn't as cool as cpanminus, but at least you don't have to download anything to get this to work.
8 年多之前 回复

For Strawberry Perl, try:

cpan -u
csdnceshi63
elliott.david For regular Perl too. From the man page: -u Upgrade all installed modules. Blindly doing this can really break things, so keep a backup.
4 年多之前 回复
csdnceshi73
喵-见缝插针 Also works for usual perl it seems (at least on Linux).
5 年多之前 回复
csdnceshi53
Lotus@ That did the trick! Cheers.
接近 7 年之前 回复

upgrade

BTW there is a help command.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐