Cpan 模組安裝失敗
我正在嘗試安裝 Inline::MakeMaker Perl 模組(包括 Inline::C),但在安裝 Inline::C 時失敗(似乎找不到“make”,儘管 make 安裝在 /usr/bin 下)。
這是在帶有 Perl v5.18.2(從 /usr/local/perl 下的原始碼安裝)的 CentOS 6 上。
這是我的安裝嘗試的輸出(我將輸出分為三部分,以便於閱讀)。
這是第一部分(沒有錯誤):
[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 中,它在 PATH 中。
我進行了強制安裝(因為一個失敗的測試似乎有問題):
cpan -f -i Inline::MakeMaker
有了這個,它安裝得很好,我沒有任何問題。
問題似乎是 Inline.pm “sub env_untaint{}” 部分的變化。
對 dir 可寫性的新測試不知何故採取了“製造”的方式,所以它當然失敗了。值得注意的是,有一個註釋掉的部分:
# Was: # join ':', grep...
如果你恢復舊程式碼,並在 env_untaint 子中註釋掉它上面
Was: join
的新程式碼, , ,它應該成功,安裝走了。join``make clean``perl Makefile.PL``make test