perl DBI 模块安装出错

perl DBI module installation erroring out

perl DBI 模块安装出错。

使用 -Dinstallprefix 选项在非标准位置安装了 perl 5.32.1

./Configure -Dinstallprefix=/test/user/home/perl -des
make
make test
make install

/test/user/home/perl/bin/perl -version
This is perl 5, version 32, subversion 1 (v5.32.1) built for x86_64-linux

设置 PERL5LIB 环境变量

export PERL5LIB="/test/user/home/perl/lib/5.32.1:/test/user/home/perl/lib/site_perl/5.32.1:/test/user/home/perl/lib/5.32.1/x86_64-linux"

which perl
/test/user/home/perl/bin/perl

已下载 DBI-1.643 压缩包,在提取执行 Makefile.PL 后失败

perl Makefile.PL

Warning: PERL_LIB (/perl/lib/5.32.1) seems not to be a perl library directory
        (strict.pm not found) at /test/user/home/perl/lib/5.32.1/ExtUtils/MM_Unix.pm line 1934.
Have /test/user/home/perl/lib/5.32.1/x86_64-linux
Want /perl/lib/5.32.1/x86_64-linux
Your perl and your Config.pm seem to have different ideas about the
architecture they are running on.
Perl thinks: [x86_64-linux]
Config says: [x86_64-linux]
This may or may not cause problems. Please check your installation of perl
if you have problems building this extension.
Can't stat /perl/lib/5.32.1: No such file or directory
 at Makefile.PL line 280.
Can't stat /perl/lib/5.32.1/x86_64-linux: No such file or directory
 at Makefile.PL line 280.
Failed to opendir '/perl/lib/5.32.1/x86_64-linux/CORE' to find header files: No such file or directory at /test/user/home/perl/lib/5.32.1/ExtUtils/MM_Any.pm line 3048.

发现不存在的路径引用自@INC

perl -e "print \"@INC\""

/test/user/home/perl/lib/5.32.1 /test/user/home/perl/lib/site_perl/5.32.1 /test/user/home/perl/lib/5.32.1/x86_64-linux
/perl/lib/site_perl/5.32.1/x86_64-linux /perl/lib/site_perl/5.32.1 /perl/lib/5.32.1/x86_64-linux /perl/lib/5.32.1

有人可以指导我从@INC 获得这些不存在的路径吗

/perl/lib/site_perl/5.32.1/x86_64-linux /perl/lib/site_perl/5.32.1 /perl/lib/5.32.1/x86_64-linux /perl/lib/5.32.1

有什么方法可以限制@INC 附加不存在的路径吗?

我想你只需要 -Dprefix=/...。还有其他事情也需要在正确的地方结束。你不需要设置 PERL5LIB,因为 perl 应该使用你的前缀作为它的默认 @INC。你的 perl -V 显示什么?

有一个installprefix,但它的目的是在一台机器上编译并在另一台机器上安装。但是,INSTALL 文档也建议不要使用它。这就是你想要做的吗?

至于其他目录,INSTALL 文档描述了 @INC 中出现的各种目录。

谢谢@brian 为我指明了正确的方向。

以下是@INC 包含不存在目录的根本原因。

最后一次在 perl 安装过程中至少有一次我 运行 按照命令

./Configure -des -Dprefix=/perl

Use relocatable @INC? [n]
Pathname where the private library files will reside? (~name ok)
[/perl/lib/5.32.1]
Where do you want to put the public architecture-dependent libraries? (~name ok)
[/perl/lib/5.32.1/x86_64-linux]
Pathname for the site-specific library files? (~name ok)
[/perl/lib/site_perl/5.32.1]
Pathname for the site-specific architecture-dependent library files? (~name ok)
[/perl/lib/site_perl/5.32.1/x86_64-linux]

然后执行make命令。后来由于其他错误使测试失败。

然后没有 运行 make distclean 命令,我重新 运行 配置
-Dinstallprefix 选项

./Configure -Dinstallprefix=/test/user/home/perl -des

按如下方式填充@INC

/test/user/home/perl/lib/5.32.1 /test/user/home/perl/lib/site_perl/5.32.1 /test/user/home/perl/lib/5.32.1/x86_64-linux
/perl/lib/site_perl/5.32.1/x86_64-linux /perl/lib/site_perl/5.32.1 /perl/lib/5.32.1/x86_64-linux /perl/lib/5.32.1

要解决此问题,请执行以下步骤,

make distclean  

./Configure -des -Dprefix=/test/user/home/perl -Dusethreads

现在 @INC 已正确填充

@INC:
    /test/user/home/perl/lib/site_perl/5.32.1/x86_64-linux-thread-multi
    /test/user/home/perl/lib/site_perl/5.32.1
    /test/user/home/perl/lib/5.32.1/x86_64-linux-thread-multi
    /test/user/home/perl/lib/5.32.1

现在 DBI 安装 运行 成功。