【问题标题】:Modules install successfully but cannot be found模块安装成功但找不到
【发布时间】:2015-05-11 21:36:46
【问题描述】:

我想知道为什么我得到“安装依赖项失败:未安装模块'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
  1. 它告诉我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
  1. 我回到我最初想要的 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

谁能告诉我为什么会发生这种情况以及我可以做些什么来阻止它?如果您需要任何我遗漏的更多信息,请告诉我。

谢谢

【问题讨论】:

  • URI 安装在哪里? cpanm 是从哪里读到的?
  • @choroba : hamid@caspian:~$ perl -MURI -e 'print $INC{"Time/HiRes.pm"}' 在 @INC 中找不到 URI.pm
  • 您的cpanm 安装在一个奇怪的位置;它是否通过正确的perl 运行?
  • @friedo 让工作更顺利perlbrew 可以install its own cpanm - 所以这可能没问题。如果您将自己的local::lib 和像$PERL5LIB 这样的环境变量与perlbrew 的环境混合使用,可能会造成干扰(当然可以使用local::lib 环境“内部” perlbrew 和lib 命令)。 @Hamster 是否为您的 perlbrew 使用的 perl 版本安装了 URI? (i.e. 是 perlbrew 目录层次结构中存在的文件)。
  • 看起来它正在安装在某个地方:-) 设置好PERLBREW_ env vars 了吗?像PERL_CPANM_OPTPERL_LOCAL_LIB_ROOTPERL5LIB 之类的东西出现在您的环境中可能会搞砸?

标签: perl cpan perlbrew cpanm


【解决方案1】:

感谢https://stackoverflow.com/users/2019415/g-cito

hamid@里海:~$ PERL_MM_OPT=""; PERL_MB_OPT="";

已经完成了工作:)

local::lib 搞砸了。 URI.pm 已安装但不在 perlbrew 目录下。

【讨论】:

  • 如果您配置了local::lib,您应该检查您的.bashrc(或您的shell 的等效项); PERL_MM_OPTPERL_MB_OPT 可能设置在那里。
  • 如果您想接受它,请添加 cmets 作为答案 :-) 请务必注意 @ThisSuitIsBlackNot 的建议 ++
【解决方案2】:

使用perlbrew,您可以安装perlbrew specific cpanm,这有助于安装到使用perlbrew 工具安装/管理的各种perls/。我发现这非常有效。

但是,如果你混入自己的local::lib 并设置相关的环境变量,如PERL5LIBPERL_MM_OPTPERL_MB_OPT 等,perlbrew可能会变得混乱。 em>(例如参见@cjm 在perlbrew and local::lib at the same time? 中的帖子)。其中一些环境变量可以与 perlbrew 自己的环境交互和干扰,因此通常最好避免混合它们,或者只是让 perlbrew 使用自己的这些变量版本来管理环境。

当然可以使用 local::lib 环境 "inside" perlbrew 与 lib 命令)并做非常复杂的事情来测试不同的 perl 版本,发布一个有要求的应用程序(cf Carton)。在我自己的环境中,我能够管理系统 perl;用户安装了使用系统 perl 的local::lib;和大量的 perlbrew perls,所有这些都明智地使用了环境变量(幸好在版本之间迁移时临时设置)。

这种设置会很快变得复杂,并且难以复制。 perlbrew 的最大优势之一是您可以轻松地在多台机器上设置匹配的 perl 环境;或同一台机器上的不同 perl 环境。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-12-23
    • 1970-01-01
    • 1970-01-01
    • 2018-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多