Linux CPAN 在 ubuntu 上出现各种错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6876295/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 05:21:21  来源:igfitidea点击:

CPAN giving all sorts of errors on ubuntu

linuxperlubuntucpan

提问by roymustang86

I am just trying to run a simple perl program to import data from xml and export it to database.

我只是想运行一个简单的 perl 程序来从 xml 导入数据并将其导出到数据库。

Use Mysql; did not work, so I used DBD::mysql instead after failing to get Mysql.pm from cpan.

使用Mysql;没有用,所以我在无法从 cpan 获取 Mysql.pm 后使用 DBD::mysql 代替。

However, I am unable to install anything. I am trying to install xml parser module, but cpan gives these errors no matter what module you try to install.

但是,我无法安装任何东西。我正在尝试安装 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

Am I doing something wrong? I tried searching for these errors, but no one has a right solution. Is there some setting in the config I should change?

难道我做错了什么?我尝试搜索这些错误,但没有人有正确的解决方案。我应该更改配置中的某些设置吗?

采纳答案by Arjuna Del Toso

If nobody has an answer for your particular problem I would probably just try with a new cpan, something like:

如果没有人对您的特定问题有答案,我可能会尝试使用新的 cpan,例如:

cd && mv .cpan .cpan-bak

and then trying to install the module again.

然后再次尝试安装模块。

Hope this helps.

希望这可以帮助。

回答by Bopper

I had the same problem when my connection to the perl site timed out. The /root/.cpan/sources/modules/02packages.details.txt.gzcontained only the information that the network timed out, and the /root/.cpan/sources/modules/03modlist.data.gzwas also junk.

当我与 perl 站点的连接超时时,我遇到了同样的问题。在/root/.cpan/sources/modules/02packages.details.txt.gz该网络超时仅包含信息,/root/.cpan/sources/modules/03modlist.data.gz也是垃圾。

By removing just these files and trying again when the network was less busy, the files were then fetched correctly and everything worked fine again.

通过仅删除这些文件并在网络不太忙时重试,然后正确获取文件并且一切正常。

回答by Damian Green

Check that your version of "cpan" (your installation program) matches your "perl" version...

检查您的“cpan”版本(您的安装程序)是否与您的“perl”版本匹配...

Check this by doing: cpan --versionand perl -v

通过执行以下操作检查: cpan --versionperl -v

I came across this same error while trying to install another module and it turned out that the version of "cpan" that I was using was compiled as part of the 5.8.8 perl package but the version of "perl" that is set as default here at work is version 5.8.5, so cpan was compiling the C code using references to the wrong 5.8.8 perl base library that was not compatible when implemented by the 5.8.5 perl base.

我在尝试安装另一个模块时遇到了同样的错误,结果我使用的“cpan”版本被编译为 5.8.8 perl 包的一部分,但“perl”版本设置为默认值这里使用的是 5.8.5 版本,因此 cpan 使用对错误的 5.8.8 perl 基础库的引用来编译 C 代码,该库在由 5.8.5 perl 基础实现时不兼容。

The simple solution was to call the proper "cpan" program using the full path "/usr/.../perl/5.8.5/bin/cpan module_name".

简单的解决方案是使用完整路径“ /usr/.../perl/5.8.5/bin/cpan module_name”调用正确的“cpan”程序。

This little inconsistency of having different binaries of different version packages being default is a an oversight by our administrators and has really caused a lot of grief.

这种默认不同版本包的不同二进制文件的小不一致是我们管理员的疏忽,确实引起了很多悲痛。

回答by Flow

I had a similar problem.

我有一个类似的问题。

Situation:

情况:

trying to install Catalyst::Plugin::AutoCRUD

尝试安装 Catalyst::Plugin::AutoCRUD

using perl version: perlbrew-5.14.2

使用 perl 版本:perlbrew-5.14.2

solution:

解决方案:

problem was the sudo i was prefacing to the cpan install command like this:

问题是我在 cpan install 命令前面使用了 sudo,如下所示:

DIDNT WORK:

没有工作:

sudo cpan Catalyst::Plugin::AutoCRUD

WORKS:

作品:

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

Reason: because i had perlbrew + cpan installed under my user account, NOT as root, all subsequent cpan module installs must be made with same user.

原因:因为我在我的用户帐户下安装了 perlbrew + cpan,而不是以 root 身份安装,所有后续的 cpan 模块安装都必须使用相同的用户进行。

回答by sebasCR1984

In my case, I needed to run cpan with sudo -H to get my local network setitngs (like proxies). So: cd && mv .cpan .cpan-bak

就我而言,我需要使用 sudo -H 运行 cpan 来获取我的本地网络设置(如代理)。所以: cd && mv .cpan .cpan-bak

Then: sudo -H cpan

然后: sudo -H cpan

Default answered to cpan configs (this time the errors didn't appear).

默认回答 cpan 配置(这次没有出现错误)。

Then I was able to install any module.

然后我就可以安装任何模块了。

回答by ppal

To resolve this issue I had to install cpanm on Centos7.

为了解决这个问题,我必须在 Centos7 上安装 cpanm。

Steps:

脚步:

yum install perl-devel
yum install perl-CPAN
curl -L http://cpanmin.us | perl - --sudo App::cpanminus

Add local bin (/usr/local/bin) to PATHusing:

将本地 bin ( /usr/local/bin)添加到PATH使用:

PATH=$PATH:/usr/local/bin

Links

链接