模块安装成功但无法找到

3
我想知道为什么我已经安装了依赖项,但仍然收到“安装依赖项失败:模块'Module :: Name'未安装”的错误。 我正在使用perlbrewcpanm。 以下是我尝试安装许多模块时发生的示例:
  1. 我尝试按照以下方式安装URI :: ws
hamid@caspian:~$ /home/hamid/perl5/perlbrew/bin/cpanm --installdeps URI::ws
--> Working on URI::ws
Fetching http://www.cpan.org/authors/id/P/PL/PLICEASE/URI-ws-0.03.tar.gz ... OK
Configuring URI-ws-0.03 ... OK
==> Found dependencies: URI
--> Working on URI
Fetching http://www.cpan.org/authors/id/E/ET/ETHER/URI-1.67.tar.gz ... OK
Configuring URI-1.67 ... OK
Building and testing URI-1.67 ... OK
Successfully installed URI-1.67
! Installing the dependencies failed: Module 'URI' is not installed
! Bailing out the installation for URI-ws-0.03.
1 distribution installed
2. 这告诉我URI未安装。因此,我按以下方式安装了URI
hamid@caspian:~$ /home/hamid/perl5/perlbrew/bin/cpanm URI
--> Working on URI
Fetching http://www.cpan.org/authors/id/E/ET/ETHER/URI-1.67.tar.gz ... OK
Configuring URI-1.67 ... OK
Building and testing URI-1.67 ... OK
Successfully installed URI-1.67
1 distribution installed
我回到最初想要的 URI::ws,下面是它的内容:
hamid@caspian:~$ /home/hamid/perl5/perlbrew/bin/cpanm URI::ws
--> Working on URI::ws
Fetching http://www.cpan.org/authors/id/P/PL/PLICEASE/URI-ws-0.03.tar.gz ... OK
Configuring URI-ws-0.03 ... OK
==> Found dependencies: URI
--> Working on URI
Fetching http://www.cpan.org/authors/id/E/ET/ETHER/URI-1.67.tar.gz ... OK
Configuring URI-1.67 ... OK
Building and testing URI-1.67 ... OK
Successfully installed URI-1.67
! Installing the dependencies failed: Module 'URI' is not installed
! Bailing out the installation for URI-ws-0.03.
1 distribution installed

有人能告诉我这是为什么,以及我可以做些什么来阻止它吗?如果还有我遗漏的需要您了解的信息,请告诉我。

谢谢


1
URI 被安装在哪里?cpanm 试图从哪里读取它? - choroba
@choroba: hamid@caspian:~$ perl -MURI -e 'print $INC{"Time/HiRes.pm"}' 无法在 @INC 中找到 URI.pm - Hamster
您的cpanm安装在一个奇怪的位置;它是否通过正确的perl运行? - friedo
4
为了使事情更加顺利,Perlbrew可以安装它自己的 cpanm(请参考 http://www.perlbrew.pl/Perlbrew-and-Friends.html) - 所以这可能是可以的。可能会干扰事情的是,如果您将自己的 local::lib 和环境变量(例如 $PERL5LIB)与 Perlbrew 的环境混合使用(当然也可以使用 lib 命令在 Perlbrew 中“内部”使用 local::lib 环境)。请问您的 Perlbrew 使用的版本中是否已安装URI?(即,在 Perlbrew 目录层次结构中是否存在文件)。 - G. Cito
@G.Cito,我正在使用Perl的最新版本(5.20.2),不过执行find ~/perl5/perlbrew/ -name "*URI*"没有任何输出。 - Hamster
2
看起来它正在某个地方安装 :-) 所有正确的 PERLBREW_ 环境变量都设置了吗?你的环境中是否存在类似于 PERL_CPANM_OPTPERL_LOCAL_LIB_ROOTPERL5LIB 的东西可能会搞砸事情? - G. Cito
2个回答

5
感谢https://stackoverflow.com/users/2019415/g-cito的帮助 🙂

hamid@caspian:~$ PERL_MM_OPT=""; PERL_MB_OPT="";

已�解决了问题 :)

local::lib 引起了一些问题,URI.pm 已�安装但�在 perlbrew 目录下。


2
如果您已经配置了 local::lib,则应检查您的 .bashrc(或适用于您的 shell 的等效文件);PERL_MM_OPTPERL_MB_OPT 可能在其中设置。 - ThisSuitIsBlackNot
如果您想接受它,请将注释添加为答案 :-) 一定要听取@ThisSuitIsBlackNot的建议++ - G. Cito
这个解决方案对我有效。编辑/root/.bashrc文件,将变量设置为PERL_MM_OPT=""; PERL_MB_OPT=""; 然后使用以下命令重新加载bash:source /root/.bashrc,然后重新安装模块。 - Y.K.

2
使用perlbrew,您可以安装一个专门针对cpanm的perlbrew,它便于在使用perlbrew工具安装/管理的各种perls/上进行安装。我发现这非常有效。
然而,如果您混合使用自己的local::lib并设置相关环境变量(如PERL5LIBPERL_MM_OPTPERL_MB_OPT等),perlbrew可能会变得混乱,一些这些环境变量可能会与perlbrew自己的环境相互作用和干扰,因此最好避免混合使用它们或者仅让perlbrew使用其自己的版本来管理环境。请参见例如@cjm在perlbrew and local::lib at the same time?中的帖子。
当然,可以在 perlbrew 中使用 local::lib(通过 lib 命令)并进行复杂的测试,包括不同版本的 perl 的需求(参见 Carton)。在我的环境中,我能够管理系统 perl;一个用户安装了使用系统 perl 的 local::lib;而且通过巧妙地使用环境变量来管理大量的 perlbrew perl(幸运的是这只是迁移版本时的临时设置)。
这种设置可能会很快变得复杂,并且难以复制。perlbrew 最大的优势之一是你可以轻松地在多台机器上设置匹配的 perl 环境,或在同一台机器上设置不同的 perl 环境。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接