如何将所有 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

csdnceshi79
python小菜 +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 and nimble to use that I hardly ever go back to CPAN shell. To upgrade all of your modules in one go, the command is:

cpan-outdated -p | cpanm

I recommend you install cpanminus like the docs describe:

curl -L https://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:

weixin_41568184
叼花硬汉 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 年多之前 回复
weixin_41568183
零零乙 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 年多之前 回复
weixin_41568183
零零乙 [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 年多之前 回复
csdnceshi60
℡Wang Yan "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 年之前 回复
csdnceshi64
游.程 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.

For Strawberry Perl, try:

cpan -u
csdnceshi54
hurriedly% 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 年多之前 回复
csdnceshi59
ℙℕℤℝ Also works for usual perl it seems (at least on Linux).
5 年多之前 回复
csdnceshi66
必承其重 | 欲带皇冠 That did the trick! Cheers.
接近 7 年之前 回复

upgrade

BTW there is a help command.

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.

csdnceshi53
Lotus@ For those having problems with this command; Try running cpan shell via cpan, and then run the upgrade /(.*)/ in the cpan shell.
4 年多之前 回复
csdnceshi52
妄徒之命 this don't work
6 年多之前 回复
weixin_41568174
from.. 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 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐