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

Tom*_*asz 8 perl install cpan

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

'makepl_arg' => q[PREFIX=~/lib],
Run Code Online (Sandbox Code Playgroud)

当我尝试运行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";
Run Code Online (Sandbox Code Playgroud)

我明白了

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());
Run Code Online (Sandbox Code Playgroud)

CSV_XS.so存在于上述目录中

bri*_*foy 5

安装模块时,是否观察了输出?它说它安装模块在哪里?在lib中查找.你看到了你期望的下一个目录吗?

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

% find ~/lib -name CSV_XS.so

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

我希望你能以lib/lib某种方式在那里.这PREFIX只是前缀,并且安装程序将其他目录部分附加到该基本路径.这包括lib,man,bin .


Fay*_*Lam 2

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

  • 在这里提供一些简短的命令将非常有用,这些命令显示如何使用local :: lib将模块安装到本地库目录中. (30认同)
  • 你能解释一下*为什么*你建议`local :: lib`?它是什么,为什么它比这里提出的其他解决方案更好? (8认同)
  • 我们如何在以下情况下执行此操作:`无法在@INC中找到local/lib.pm ....(我们无法安装它,因此需要在一个homedir下面安装模块) (2认同)