Perl 编译:'Too many levels of symbolic links'

perl compilation: 'Too many levels of symbolic links'

在 Linux 中,当 运行 make test command[=13= 时,perl 安装失败]

t/op/exec ...................................................... # Failed test 17 - at op/exec.t line 114
# $! eq 40, 'Too many levels of symbolic links'
FAILED at test 17

错误未指示哪个符号 link 失败。

遵循的步骤:

- Download perl archive from https://www.cpan.org/src/ 

- [user@hostname perl-5.28.3]$  tar -xvzf perl-5.28.3.tar.gz

- [user@hostname perl-5.28.3]$  cd perl-5.28.3

- [user@hostname perl-5.28.3]$  ./Configure -des -Dinstallprefix=<installation directory>

- [user@hostname perl-5.28.3]$  make

- [user@hostname perl-5.28.3]$  make test

Failed 2 tests out of 2464, 99.92% okay.
        ../cpan/Time-Local/t/Local.t
        op/exec.t
Elapsed: 1317 sec
u=12.87  s=34.02  cu=548.85  cs=488.76  scripts=2464  tests=1158447
make: *** [test] Error 1



[user@hostname perl-5.28.3]$  t/TEST op/exec.t
t/op/exec ... # Failed test 17 - at op/exec.t line 114
# $! eq 40, 'Too many levels of symbolic links'
FAILED at test 17
Failed 1 test out of 1, 0.00% okay.
        op/exec.t

已验证其他 perl 版本也发生了相同的行为,这表明我的安装环境存在一些问题。

任何指针都会有所帮助。

感谢@choroba 指点。

以下是根本原因。

<perl-5.28.3>/t/op/exec.t 文件中,我们在第 114 行附近找到以下内容:

$rc = system { "lskdfj" } "lskdfj";
unless( ok($rc == 255 << 8 or $rc == -1 or $rc == 256 or $rc == 512) ) {
    print "# $rc == $rc\n";
}

unless ( ok( $! == 2  or  $! =~ /\bno\b.*\bfile/i or  
             $! == 13 or  $! =~ /permission denied/i or
             $! == 22 or  $! =~ /invalid argument/i  ) ) {
    diag sprintf "$! eq %d, '%s'\n", $!, $!;
}

在我的环境中,PATH 环境变量值为

[user@hostname perl-5.28.3]$ echo $PATH
/bin:/usr/lib64/qt-3.3/bin:/bin:/usr/bin:/usr/dev_infra/platform/bin:/usr/dev_infra/generic/bin:/usr/local/bin:/usr/local/ade/bin

在此 PATH 中,对于以下路径,ls 尝试抛出错误 'Too many levels of symbolic links'

[user@hostname perl-5.28.3]$ ls -i  /usr/local/bin /usr/local/ade/bin
ls: cannot access /usr/local/bin: Too many levels of symbolic links
ls: cannot access /usr/local/ade/bin: Too many levels of symbolic links
    
[user@hostname perl-5.28.3]$ ls -ltr /usr/local
lrwxrwxrwx. 1 root root   20 Mar 30  2017 bin -> ./packages/local/bin
lrwxrwxrwx. 1 root root   18 Mar 30  2017 ade -> /usr/local/nde/ade

从 PATH 中删除有问题的路径后,make test 运行 成功

[user@hostname perl-5.28.3]$  export PATH=/bin:/usr/lib64/qt-3.3/bin:/bin:/usr/bin:/usr/dev_infra/platform/bin:/usr/dev_infra/generic/bin

[user@hostname perl-5.28.3]$  make test

All tests successful.
Elapsed: 1611 sec
u=14.47  s=44.63  cu=731.82  cs=575.84  scripts=2474  tests=1209537