2011-07-29 77 views
1

我只是試圖運行一個簡單的Perl程序從XML導入數據並將其導出到數據庫。CPAN在Ubuntu上給出各種錯誤

使用Mysql;沒有工作,所以我沒有從cpan獲取Mysql.pm之後使用了DBD :: mysql。

但是,我無法安裝任何東西。我正在嘗試安裝xml解析器模塊,但無論您嘗試安裝哪個模塊,cpan都會給出這些錯誤。

install xml::parser 
CPAN: Storable loaded ok (v2.20) 
Going to read '/root/.cpan/sources/authors/01mailrc.txt.gz' 
CPAN: Compress::Zlib loaded ok (v2.02) 
............................................................................DONE 
Going to read '/root/.cpan/sources/modules/02packages.details.txt.gz' 
Warning: Your /root/.cpan/sources/modules/02packages.details.txt.gz does not contain a Line-Count header. 
Please check the validity of the index file by comparing it to more 
than one CPAN mirror. I'll continue but problems seem likely to 
happen. 
CPAN: Time::HiRes loaded ok (v1.9719) 
Warning: Your /root/.cpan/sources/modules/02packages.details.txt.gz does not contain a Last-Updated header. 
Please check the validity of the index file by comparing it to more 
than one CPAN mirror. I'll continue but problems seem likely to 
happen. 
DONE 
Going to read '/root/.cpan/sources/modules/03modlist.data.gz' 
Catching error: "Can't locate object method \"data\" via package \"CPAN::Modulelist\" (perhaps you forgot to load \"CPAN::Modulelist\"?) at (eval 29) line 1.\cJ at /usr/share/perl/5.10/CPAN/Index.pm line 518\cJ\cICPAN::Index::rd_modlist('CPAN::Index', '/root/.cpan/sources/modules/03modlist.data.gz') called at /usr/share/perl/5.10/CPAN/Index.pm line 85\cJ\cICPAN::Index::reload('CPAN::Index') called at /usr/share/perl/5.10/CPAN.pm line 955\cJ\cICPAN::exists('CPAN=HASH(0xa225610)', 'CPAN::Module', 'xml::parser') called at /usr/share/perl/5.10/CPAN/Shell.pm line 1243\cJ\cICPAN::Shell::expandany('CPAN::Shell', 'xml::parser') called at /usr/share/perl/5.10/CPAN/Shell.pm line 1639\cJ\cICPAN::Shell::rematein('CPAN::Shell', 'install', 'xml::parser') called at /usr/share/perl/5.10/CPAN/Shell.pm line 1935\cJ\cICPAN::Shell::__ANON__('CPAN::Shell', 'xml::parser') called at /usr/share/perl/5.10/CPAN.pm line 375\cJ\cIeval {...} called at /usr/share/perl/5.10/CPAN.pm line 372\cJ\cICPAN::shell() called at /usr/bin/cpan line 198\cJ" at /usr/share/perl/5.10/CPAN.pm line 391 
    CPAN::shell() called at /usr/bin/cpan line 198 
Going to read '/root/.cpan/sources/authors/01mailrc.txt.gz' 
............................................................................DONE 
Going to read '/root/.cpan/sources/modules/02packages.details.txt.gz' 
Warning: Your /root/.cpan/sources/modules/02packages.details.txt.gz does not contain a Line-Count header. 
Please check the validity of the index file by comparing it to more 
than one CPAN mirror. I'll continue but problems seem likely to 
happen. 
Warning: Your /root/.cpan/sources/modules/02packages.details.txt.gz does not contain a Last-Updated header. 
Please check the validity of the index file by comparing it to more 
than one CPAN mirror. I'll continue but problems seem likely to 
happen. 
cpanDONE 
Going to read '/root/.cpan/sources/modules/03modlist.data.gz' 
No history written (no histfile specified). 
Lockfile removed. 
Can't locate object method "data" via package "CPAN::Modulelist" (perhaps you forgot to load "CPAN::Modulelist"?) at (eval 31) line 1. 
at /usr/share/perl/5.10/CPAN/Index.pm line 518 
    CPAN::Index::rd_modlist('CPAN::Index', '/root/.cpan/sources/modules/03modlist.data.gz') called at /usr/share/perl/5.10/CPAN/Index.pm line 85 
    CPAN::Index::reload('CPAN::Index') called at /usr/share/perl/5.10/CPAN.pm line 692 
    CPAN::all_objects('CPAN=HASH(0xa225610)', 'CPAN::Distribution') called at /usr/share/perl/5.10/CPAN/Shell.pm line 1046 
    CPAN::Shell::failed('CPAN::Shell', 2, 1) called at /usr/share/perl/5.10/CPAN.pm line 413 
    eval {...} called at /usr/share/perl/5.10/CPAN.pm line 413 
    CPAN::shell() called at /usr/bin/cpan line 198 

我做錯了什麼?我試圖尋找這些錯誤,但沒有人有正確的解決方案。我應該改變配置中的設置嗎?

+0

如果您正在安裝系統Perl,您必須在sudo下運行cpan。如果你設置一個perlbrew Perl並將你的模塊安裝到本地Perl,那麼問題就會消失。 – DavidO

+1

嘗試刪除似乎已損壞的'/ root/.cpan/sources/modules/02packages.details.txt.gz',然後重試。如果這也行不通,我會按照下面的Arjuna Del Toso的建議。 – salva

+2

@DavidO:不,你只需要在mbuild_install_build_command和make_install_make_command中有CPAN配置包括sudo。但看起來他已經以root身份運行了。 – ysth

回答

12

如果沒有人對您的特定問題的答案,我可能只是一個新的嘗試CPAN,像:

cd && mv .cpan .cpan-bak 

,然後嘗試再次安裝該模塊。

希望這會有所幫助。

+0

由於某些原因,鏡像索引文件失敗,因此像您所解釋的那樣重新啓動會有所幫助。 – daxim

+0

Yess,它工作。謝謝 – roymustang86

+0

在2014年,這幫助了我!非常感謝:) –

2

當我連接到perl站點超時時,我遇到了同樣的問題。 /root/.cpan/sources/modules/02packages.details.txt.gz僅包含網絡超時的信息,並且/root/.cpan/sources/modules/03modlist.data.gz也是垃圾。

通過僅刪除這些文件並在網絡不太忙時再次嘗試,然後文件被正確提取並且再次正常工作。

2

檢查你的 「CPAN」(安裝程序)的版本的 「perl」 的版本相匹配......

選中此做:CPAN --version的perl -v

我試圖安裝另一個模塊時遇到了同樣的錯誤,結果證明我使用的「cpan」版本是作爲5.8.8 perl軟件包的一部分編譯的,但是設置爲「perl」的版本這裏默認的工作版本是5.8.5,因此cpan使用對不兼容的錯誤5.8.8 perl基礎庫的引用來編譯C代碼母雞由5.8.5 perl基地實施。

簡單的解決方案是使用完整路徑「/usr/.../perl/5.8.5/bin/cpan module_name_name」調用正確的「cpan」程序。

將不同版本軟件包的不同二進制文件作爲默認值的這種小小的不一致是我們的管理員的疏忽,並且真的引起了很大的悲傷。

4

我有類似的問題。

現狀:

嘗試安裝催化劑::插件:: AutoCRUD

用perl版本:perlbrew-5.14。2

溶液:

問題是我被作序的CPAN這樣安裝命令須藤:

沒有工作:

sudo cpan Catalyst::Plugin::AutoCRUD 

WORKS:

chown -R myusername:myusergroup ~/.cpan 
cpan Catalyst::Plugin::AutoCRUD 

原因:因爲我的perlbrew + cpan安裝在我的用戶帳戶下,而不是作爲root用戶,所有後續服務uent cpan模塊安裝必須由同一個用戶完成。