Cpan 模块安装失败

Cpan 模块安装失败

我正在尝试安装 Inline::MakeMaker Perl 模块(包括 Inline::C),但是安装 Inline::C 时失败(似乎找不到“make”,尽管 make 安装在 /usr/bin 下)。

这是在 CentOS 6 上安装的 Perl v5.18.2(从 /usr/local/perl 下的源代码安装)。

这是我安装尝试的输出(我将输出分为三个部分以便于阅读)。

这是第一部分(没有错误):

[root@xyz .cpan]# cpan -i Inline::MakeMaker
Reading '/root/.cpan/Metadata'
  Database was generated on Tue, 01 Apr 2014 19:06:25 GMT
Running install for module 'Inline::MakeMaker'
Running make for S/SI/SISYPHUS/Inline-0.54.tar.gz
Checksum for /root/.cpan/sources/authors/id/S/SI/SISYPHUS/Inline-0.54.tar.gz ok

  CPAN.pm: Building S/SI/SISYPHUS/Inline-0.54.tar.gz

Checking if your kit is complete...
Looks good

Inline::C is packaged with Inline.pm because it is the most commonly used
Inline Language Support Module (ILSM).

See also: Inline::ASM, ::Awk, ::BC, ::Basic, ::Befunge, ::CPP (C++), ::CPR,
          ::Foo, ::Guile, ::Java, ::Octave, ::PERL, ::Python, ::Ruby, ::TT,
          ::Tcl and ::WebChat.

Config.pm indicates that your version of Perl was built with this C compiler:

    cc

I have located this compiler on your system.

Do you want to install Inline::C? [y] y
Writing Makefile for Inline::C
Writing MYMETA.yml and MYMETA.json
Writing Makefile for Inline
Writing MYMETA.yml and MYMETA.json
cp lib/Inline/MakeMaker/Changes blib/lib/Inline/MakeMaker/Changes
cp Inline.pm blib/lib/Inline.pm
AutoSplitting blib/lib/Inline.pm (blib/lib/auto/Inline)
cp Inline-API.pod blib/lib/Inline-API.pod
cp Inline-Support.pod blib/lib/Inline-Support.pod
cp lib/Inline/denter.pm blib/lib/Inline/denter.pm
AutoSplitting blib/lib/Inline/denter.pm (blib/lib/auto/Inline/denter)
cp lib/Inline/MakeMaker.pm blib/lib/Inline/MakeMaker.pm
cp lib/Inline/Foo.pm blib/lib/Inline/Foo.pm
cp Inline.pod blib/lib/Inline.pod
cp Inline-FAQ.pod blib/lib/Inline-FAQ.pod
make[1]: Entering directory `/root/.cpan/build/Inline-0.54-D_RUT7/C'
cp lib/Inline/C/ParseRegExp.pm ../blib/lib/Inline/C/ParseRegExp.pm
cp lib/Inline/C/ParseRecDescent.pm ../blib/lib/Inline/C/ParseRecDescent.pm
cp C-Cookbook.pod ../blib/lib/Inline/C-Cookbook.pod
cp C.pod ../blib/lib/Inline/C.pod
cp C.pm ../blib/lib/Inline/C.pm
Manifying ../blib/man3/Inline::C::ParseRecDescent.3
Manifying ../blib/man3/Inline::C::ParseRegExp.3
Manifying ../blib/man3/Inline::C-Cookbook.3
Manifying ../blib/man3/Inline::C.3
make[1]: Leaving directory `/root/.cpan/build/Inline-0.54-D_RUT7/C'
Manifying blib/man3/Inline.3
Manifying blib/man3/Inline-Support.3
Manifying blib/man3/Inline-API.3
Manifying blib/man3/Inline-FAQ.3
  SISYPHUS/Inline-0.54.tar.gz
  /usr/bin/make -- OK
Running make test
make[1]: Entering directory `/root/.cpan/build/Inline-0.54-D_RUT7/C'
Manifying ../blib/man3/Inline::C::ParseRecDescent.3
Manifying ../blib/man3/Inline::C::ParseRegExp.3
make[1]: Leaving directory `/root/.cpan/build/Inline-0.54-D_RUT7/C'
PERL_DL_NONLAZY=1 /usr/local/perl/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00init.t ............. ok   
t/01usages.t ........... ok   
t/02config.t ........... ok   
t/03errors.t ........... ok   
t/04create.t ........... ok   
t/05files.t ............ Skipping - couldn't load the Inline::Files module
t/05files.t ............ ok   
t/06rewrite_config.t ... ok   
t/07rewrite2_config.t .. ok   
All tests successful.
Files=8, Tests=19, 12 wallclock secs ( 0.04 usr  0.01 sys +  1.28 cusr  0.05 csys =  1.38 CPU)
Result: PASS
<snip>

错误发生的地方如下:

<snip>
make[1]: Entering directory `/root/.cpan/build/Inline-0.54-D_RUT7/C'
PERL_DL_NONLAZY=1 /usr/local/perl/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, '../blib/lib', '../blib/arch')" t/*.t
t/00init.t .............. ok   
t/01syntax.t ............ ok   
t/02config.t ............ ok   
t/03typemap.t ........... ok   
t/04perlapi.t ........... ok   
t/05xsmode.t ............ ok   
t/06parseregexp.t ....... ok   
t/07typemap_multi.t ..... ok   
t/08taint.t ............. 1/10 sh: make: No such file or directory

A problem was encountered while attempting to compile and install your Inline
C code. The command that failed was:
  make > out.make 2>&1

The build directory was:
/root/.cpan/build/Inline-0.54-D_RUT7/C/_Inline_test/build/_08taint_1_p_0965

To debug the problem, cd to the build directory, and inspect the output files.

 at ./t/08taint_1.p line 7.
    ...propagated at /root/.cpan/build/Inline-0.54-D_RUT7/C/../blib/lib/Inline/C.pm line 797.
BEGIN failed--compilation aborted at ./t/08taint_1.p line 7.
Compilation failed in require at t/08taint.t line 45.
# Looks like you planned 10 tests but ran 1.
# Looks like your test exited with 127 just after 1.
t/08taint.t ............. Dubious, test returned 127 (wstat 32512, 0x7f00)
Failed 9/10 subtests 
<snip>

以下是最后一部分:

<snip>
t/09parser.t ............ This test could take a couple of minutes to run
t/09parser.t ............ ok    
t/10callback.t .......... ok   
t/11default_readonly.t .. ok   
t/12taint_old.t ......... Skipped - applies only to perl 5.6.x
t/12taint_old.t ......... ok   
t/14void_arg.t .......... ok     
t/15ccflags.t ........... ok   
t/16ccflagsex.t ......... ok   
t/17prehead.t ........... ok   
t/18quote_space.t ....... ok     
t/19INC.t ............... ok   
t/20eval.t .............. ok   
t/21read_DATA.t ......... ok   
t/22read_DATA_2.t ....... ok   
t/23validate.t .......... ok   
t/24prefix.t ............ ok   
t/25proto.t ............. ok   

Test Summary Report
-------------------
t/08taint.t           (Wstat: 32512 Tests: 1 Failed: 0)
  Non-zero exit status: 127
  Parse errors: Bad plan.  You planned 10 tests but ran 1.
Files=25, Tests=91, 30 wallclock secs ( 0.08 usr  0.02 sys + 25.88 cusr  2.11 csys = 28.09 CPU)
Result: FAIL
Failed 1/25 test programs. 0/91 subtests failed.
make[1]: *** [test_dynamic] Error 255
make[1]: Leaving directory `/root/.cpan/build/Inline-0.54-D_RUT7/C'
make: *** [subdirs-test] Error 2
  SISYPHUS/Inline-0.54.tar.gz
  /usr/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
  reports SISYPHUS/Inline-0.54.tar.gz
Running make install
  make test had returned bad status, won't install without force

以下是我尝试调试时得到的一些数据(抱歉,这篇文章太长了):

我在调试器中手动执行了失败的测试:

cd /root/.cpan/build/Inline-0.54-Rbzd5U/C
PERL_DL_NONLAZY=1
/usr/local/perl/perls/perl-5.18.2/bin/perl -d "-MExtUtils::Command::MM" "-e" "test_harness(0, '../blib/lib', '../blib/arch')" t/08taint.t

以下是输出的摘录:

t/08taint.t ............. 1/10 sh: make: No such file or directory

A problem was encountered while attempting to compile and install your Inline
C code. The command that failed was:
  make > out.make 2>&1

The build directory was:
/root/.cpan/build/Inline-0.54-Rbzd5U/C/_Inline_test/build/_08taint_1_p_0965

To debug the problem, cd to the build directory, and inspect the output files.

 at ./t/08taint_1.p line 7.
    ...propagated at /root/.cpan/build/Inline-0.54-Rbzd5U/C/../blib/lib/Inline/C.pm line 797.
BEGIN failed--compilation aborted at ./t/08taint_1.p line 7.
Compilation failed in require at t/08taint.t line 45.

因此,失败的文件是 t/08taint_1.p(这是 t/08taint.t 第 45 行所必需的)。08taint_1.p 包含以下内容:

BEGIN {is(${^TAINT}, 1, '1: taint_is_on');};

use Inline Config =>
    UNTAINT => 1,
    DIRECTORY => '_Inline_test';

use Inline C => <<'END_OF_C_CODE';

int add(int x, int y) {
    return x + y;
}

END_OF_C_CODE

is(add(7,3), 10, 'add_test');

1;

我了解到测试工具使用上述内容来构建测试,但由于某些不为人知的原因,测试未能找到“make”。

这是 /root/.cpan/build/Inline-0.54-Rbzd5U/blib/lib/Inline/C.pm (第 781-799 行),从底部数第二行代码会产生错误:

sub compile {
    my $o = shift;

    my $build_dir = $o->{API}{build_dir};
    my $cwd = &cwd;
    ($cwd) = $cwd =~ /(.*)/ if $o->UNTAINT;

    chdir $build_dir;
    # Run these in an eval block, so that we get to chdir back to
    # $cwd if there's a failure. (Ticket #81375.)
    eval {
      $o->call('makefile_pl', '"perl Makefile.PL"', 2);
      $o->call('make', '"make"', 2);
      $o->call('make_install', '"make install"', 2);
    };
    chdir $cwd;
    die if $@; #Die now that we've done the chdir back to $cwd. (#81375)
    $o->call('cleanup', 'Cleaning Up', 2);
}

因此,上面的“make”调用失败了,但为什么呢?Make 位于 /usr/bin 中,而 /usr/bin 位于 PATH 中。

答案1

我进行了强制安装(因为一个失败的测试似乎是有故障的):

cpan -f -i Inline::MakeMaker

有了它,它安装得很好,我没有遇到任何问题。

答案2

问题似乎是 Inline.pm“sub env_untaint{}”部分的变化。

新的目录可写性测试不知何故将路径“make”了出来,因此当然会失败。值得注意的是,有一个注释掉的部分:

 # Was:       
 #           join ':', grep...

如果您恢复旧代码,并在 env_untaint 子中 Was: join注释掉其上方的新代码,,,它应该可以成功安装。joinmake cleanperl Makefile.PLmake test

相关内容