无法找到perl的Module/Build.pm模块

3

我不是perl专家(请参见此页面),但是为了使用一个包,我必须运行一些perl命令。该命令显示以下错误:

$ perl Build.PL
Can't locate Module/Build.pm in @INC (@INC contains: /home/mahmood/src/bioperl-1.6.1 /home/mahmood/src/ensembl/modules 
/home/mahmood/src/ensembl-compara/modules /home/mahmood/src/ensembl-variation/modules 
/home/mahmood/src/ensembl-funcgen/modules /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl 
/usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Build.PL line 20.
BEGIN failed--compilation aborted at Build.PL line 20.

我看到这个回复,建议首先运行cpan Module::Build来修复该错误。当我运行该命令时,会出现一系列问题(文本向导),询问镜像网址,并交互式地请求安装包的权限。似乎默认答案对问题有影响。但我也没有找到哪个问题负责这个。请在pastebin中查看完整输出。

是否有办法自动安装模块,以便将其放入脚本中用于以后的任务。

更新:

看起来我必须输入cpan.org url,但在之前的尝试中,我使用了镜像网站。我尝试了回复中提出的三个命令,但仍然遇到同样的错误:

Please enter the URL of your CPAN mirror  http://www.cpan.org
Configuration does not allow connecting to the internet.
Current set of CPAN URLs:
  http://www.cpan.org
Enter another URL or RETURN to quit: []
New urllist
  http://www.cpan.org


Please remember to call 'o conf commit' to make the config permanent!


cpan shell -- CPAN exploration and modules installation (v1.9402)
Enter 'h' for help.

cpan[1]> o conf build_requires_install_policy yes
    build_requires_install_policy [yes]
Please use 'o conf commit' to make the config permanent!


cpan[2]> o conf prerequisites_policy follow
    prerequisites_policy [follow]
Please use 'o conf commit' to make the config permanent!


cpan[3]> o conf commit
commit: wrote '/home/mahmood/.cpan/CPAN/MyConfig.pm'

cpan[4]> quit
No history written (no histfile specified).
Lockfile removed.
mahmood@cluster:Bio-DB-HTS$ perl Build.PL
Can't locate Module/Build.pm in @INC (@INC contains: /home/mahmood/src/bioperl-1.6.1 /home/mahmood/src/ensembl/modules /home/mahmood/src/ensembl-compara/modules /home/mahmood/src/ensembl-variation/modules /home/mahmood/src/ensembl-funcgen/modules /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Build.PL line 20.
BEGIN failed--compilation aborted at Build.PL line 20.

现在你需要在运行 ./Build.PL 之前先运行 cpan Module::Build - stevieb
好的。正在下载中。还需要root权限。我稍后会回来。 - mahmood
如果我想从头开始重试,删除所有临时文件的步骤是什么? - mahmood
你需要root权限,因为你正在使用系统Perl。这是完全不同的话题。我很高兴你至少已经开始了。不建议干扰系统Perl;许多人使用Perlbrew。 - stevieb
删除您的配置文件是指?只需执行 rm /home/mahmood/.cpan/CPAN/MyConfig.pm - stevieb
2个回答

6
如果您想将Module::Build安装到系统库中,那么使用预构建软件包可能更容易,而且该软件包几乎肯定适用于您的系统。
如果您使用的是类似于RedHat的Linux发行版,请尝试:
$ sudo yum install perl-Module-Build

在较新版本的 Fedora 上,可以尝试使用 dnf 代替 yum

如果您正在使用类似 Debian 的 Linux 发行版,请尝试:

$ sudo apt-get install libmodule-build-perl

好的,翻译如下:好的。谢谢。但并不是所有的软件包都在仓库里 :( 我正在为其他软件包苦苦挣扎! - mahmood

1
现在您已经配置了,您可以更改配置以避免要求您安装每个依赖项。

在命令行上(请注意,字符是字面意思...它们不是点):

cpan
o conf build_requires_install_policy yes
o conf prerequisites_policy follow
o conf commit

在手动输入响应之前,查看每个项目的描述:

cpan

o conf init build_requires_install_policy

When a module declares another one as a 'build_requires' prerequisite
this means that the other module is only needed for building or
testing the module but need not be installed permanently. In this case
you may wish to install that other module nonetheless or just keep it
in the 'build_dir' directory to have it available only temporarily.
Installing saves time on future installations but makes the perl
installation bigger.

You can choose if you want to always install (yes), never install (no)
or be always asked. In the latter case you can set the default answer
for the question to yes (ask/yes) or no (ask/no).

 <build_requires_install_policy>
Policy on installing 'build_requires' modules (yes, no, ask/yes,
ask/no)? [yes] 


o conf init prerequisites_policy

The CPAN module can detect when a module which you are trying to build
depends on prerequisites. If this happens, it can build the
prerequisites for you automatically ('follow'), ask you for
confirmation ('ask'), or just ignore them ('ignore').  Choosing
'follow' also sets PERL_AUTOINSTALL and PERL_EXTUTILS_AUTOINSTALL for
"--defaultdeps" if not already set.

Please set your policy to one of the three values.

 <prerequisites_policy>
Policy on building prerequisites (follow, ask or ignore)? [follow] 

在你设置它们之后,不要忘记执行以下操作:

o conf commit

"保存更改。"
"现在运行:"
cpan Module::Build

...最后,运行您的构建脚本:

./Build.PL

当我看到交互式软件包安装很麻烦时,我按下了ctrl+c。现在,当我运行cpan时,它会显示“抱歉,由于缺少某些参数,我们必须重新运行CPAN.pm的配置对话框...”。因此,它再次要求输入<cpan_home>和其他内容。所以我无法输入o cpan ... - mahmood
@mahmood 只需查看配置即可。默认设置非常合理,因此在第一次尝试时,只需使用所有默认设置,然后从那里开始。 - stevieb
我陷入了和之前一样的困境。它问我镜像网址的事。请查看更新的帖子。你的意思是我必须一次性完成那个交互式包安装吗? - mahmood
请跳过那个部分(按ENTER)。它正在要求额外的镜像。通常情况下您不需要任何镜像。 - stevieb
如果你的意思是“请输入您的CPAN镜像的URL”,我按下了回车键,导致该消息再次出现。正如您在完整输出中所看到的,在询问是否有ftp/http代理之后,它会要求输入镜像URL。 - mahmood

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