如何在没有root访问权限的情况下在本地安装CPAN模块(DynaLoader.pm 229行错误)?

StackOverflow https://stackoverflow.com/questions/102850

  •  01-07-2019
  •  | 
  •  

不适用于其他模块,只是举个例子。我使用CPAN设置安装了Text :: CSV_XS:

'makepl_arg' => q[PREFIX=~/lib],

当我尝试运行test.pl脚本时:

  

$ perl test.pl

#!/usr/bin/perl

use lib "/homes/foobar/lib/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi";

use Text::CSV_XS;

print "test";

我得到了

Can't load '/homes/foobar/lib/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/Text/CSV_XS/CSV_XS.so' for module Text::CSV_XS: /homes/foobar/lib/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/Text/CSV_XS/CSV_XS.so: cannot open shared object file: No such file or directory at /www/common/perl/lib/5.8.2/i686-linux/DynaLoader.pm line 229.
at test.pl line 6
Compilation failed in require at test.pl line 6.
BEGIN failed--compilation aborted at test.pl line 6.

我将错误追溯到DynaLoader.pm,它发生在这一行:

# Many dynamic extension loading problems will appear to come from
# this section of code: XYZ failed at line 123 of DynaLoader.pm.
# Often these errors are actually occurring in the initialisation
# C code of the extension XS file. Perl reports the error as being
# in this perl code simply because this was the last perl code
# it executed.

my $libref = dl_load_file($file, $module->dl_load_flags) or
    croak("Can't load '$file' for module $module: ".dl_error());

CSV_XS.so存在于上述目录

有帮助吗?

解决方案

我个人建议使用 local :: lib 。 :)

其他提示

安装模块后,您是否观看了输出?它说它安装模块在哪里?查看 lib 。你看到了你期望的下一个目录吗?

查看〜/ lib,看看eveything最终验证你的 use lib 语句中是否有正确的目录名:

<代码> %find~ / lib -name CSV_XS.so

一旦看到它的安装位置,请在 use lib (或PERL5LIB或其他)中使用该目录名。

我希望你有一个 lib / lib PREFIX 只是一个好的前缀,安装程序会将其他目录部分附加到该基本路径。这包括lib,man,bin,

请改为尝试:

'makepl_arg' => q[PREFIX=~/]

PREFIX设置要安装到的所有目录的基础(bin,lib等)。

你的'〜'也可能遇到shell扩展问题。您可以尝试自己扩展它:

'makepl_arg' => q[PREFIX=/home/users/foobar]

如果您包含用于获取所询问错误的命令,也会有所帮助。

从错误消息(“at / www / common ...”)看,您的脚本是CGI或mod_perl脚本。 Web服务器可能没有以用户'foo'的形式运行,在其安装模块的主目录下 - 可能导致Web服务器无法读取该目录。

它也可能在“ chroot jail ”中运行,这意味着您安装模块的目录可能对脚本不可见。

换句话说,仅仅因为可以看到模块,并不意味着Web服务器以及你的脚本可以这样做。您应该检查相关的文件权限,如果服务器是chrooted,那么您的模块目录是否已安装在虚拟文件系统中。

有问题的文件(CSV_XS.so)是否存在?

它是否存在于列出的位置?

如果你这样做:

set |grep PERL

输出是什么?

您是否已成功安装其他本地perl模块?

如果您有空间,我强烈建议您在自己的主目录中安装自己的perl。然后,您可以将所有内容保存在您的控制之下,并保留您自己的模块集,以及如果管理员让您使用旧版本的perl,则可以转义。 (更不用说保留自己,如果他们某天升级并省略了你所依赖的所有模块。)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top