gpt4 book ai didi

perl - 在主目录中安装 perl 模块时出现问题

转载 作者:行者123 更新时间:2023-12-02 07:40:09 31 4
gpt4 key购买 nike

我们在 HPC 集群上安装了 Perl (5.26) 作为模块环境中的模块。因为我们不想在整个集群上安装单个用户请求的所有 Perl 模块,所以我们要求他们在其目录之一(主目录、工作区等)中安装所需的 Perl 模块

我们建议使用 cpanm 和 local::lib 来安装所需的模块。 Cpanm安装在我们的集群上,用户自行安装local::lib。然后他们应该能够自己安装 perl 模块。

实际上,这仅适用于某些模块。首先,我们设置local::lib并设置环境

# 1. Install local::lib in your home
wget https://cpan.metacpan.org/authors/id/H/HA/HAARG/local-lib-2.000024.tar.gz
tar xvf local-lib-2.000024.tar.gz
cd local-lib-2.000024
# Install local::lib in your home
perl Makefile.PL --bootstrap
make test && make install

# 2. Configure local::lib, because cpanm uses this configuration. Otherwise cpanm would install modules to system perl, which is not writable for normal users
echo 'eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"' >>~/.bashrc
source ~/.bashrc;

现在我们尝试安装一个模块:

cpanm HTML::PullParser

它尝试安装依赖项 HTML::Tagset,它说 HTML::Tagset 已安装,但之后找不到依赖项。用户PERL5LIB目录下有一个Tagsat的目录,但它是空的:

Configuring HTML-Tagset-3.20 ... OK
Building and testing HTML-Tagset-3.20 ... OK
Successfully installed HTML-Tagset-3.20
! Installing the dependencies failed: Module 'HTML::Tagset' is not
installed
! Bailing out the installation for HTML-Parser-3.72.
1 distribution installed

有人经历过同样的行为并且知道如何解决这个问题吗?对于某些模块(例如 Math::CDF)它有效。

编辑以回复评论:

PERL5LIB,因此 @INC 被更改:

> set | grep ^PERL
PERL5LIB=~/perl5/lib/perl5:/opt/bwhpc/common/devel/perl/5.26/lib/site_perl/5.26.1:/opt/bwhpc/common/devel/perl/5.26/lib
PERL_BIN_DIR=/opt/bwhpc/common/devel/perl/5.26/bin
PERL_HOME=/opt/bwhpc/common/devel/perl/5.26
PERL_LIB_DIR=/opt/bwhpc/common/devel/perl/5.26/lib
PERL_LOCAL_LIB_ROOT=~/perl5
PERL_MAN_DIR=/opt/bwhpc/common/devel/perl/5.26/man
PERL_MB_OPT='--install_base "~/perl5"'
PERL_MM_OPT=INSTALL_BASE=~/perl5
PERL_VERSION=5.26

> perl -I$HOME/perl5/lib/perl5 -Mlocal::lib
PERL_MB_OPT="--install_base \"~/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=~/perl5"; export PERL_MM_OPT;

带 -v 的 cpanm 输出:

Unpacking HTML-Tagset-3.20.tar.gz
HTML-Tagset-3.20/
HTML-Tagset-3.20/Tagset.pm
HTML-Tagset-3.20/Makefile.PL
HTML-Tagset-3.20/META.yml
HTML-Tagset-3.20/MANIFEST.SKIP
HTML-Tagset-3.20/MANIFEST
HTML-Tagset-3.20/README
HTML-Tagset-3.20/t/
HTML-Tagset-3.20/t/01_old_junk.t
HTML-Tagset-3.20/t/pod.t
HTML-Tagset-3.20/t/00_about_verbose.t
HTML-Tagset-3.20/Changes
Entering HTML-Tagset-3.20
Checking configure dependencies from META.yml
Running Makefile.PL
Configuring HTML-Tagset-3.20 ... Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for HTML::Tagset
Writing MYMETA.yml and MYMETA.json
OK
Checking dependencies from MYMETA.json ...
Checking if you have ExtUtils::MakeMaker 0 ... Yes (7.24)
Building and testing HTML-Tagset-3.20 ... cp Tagset.pm blib/lib/HTML/Tagset.pm
Manifying 1 pod document
PERL_DL_NONLAZY=1 "/cluster/bwhpc/common/devel/perl/5.26/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00_about_verbose.t .. ok
t/01_old_junk.t ....... ok
t/pod.t ............... skipped: Test::Pod 1.14 required for testing POD
All tests successful.
Files=3, Tests=3, 0 wallclock secs ( 0.02 usr 0.01 sys + 0.04 cusr 0.02 csys = 0.09 CPU)
Result: PASS
Manifying 1 pod document
Appending installation info to ~/perl5/lib/perl5/x86_64-linux-thread-multi/perllocal.pod
OK
Successfully installed HTML-Tagset-3.20
Installing ~/perl5/lib/perl5/x86_64-linux-thread-multi/.meta/HTML-Tagset-3.20/install.json
! Installing the dependencies failed: Module 'HTML::Tagset' is not installed
! Bailing out the installation for HTML-Parser-3.72.
1 distribution installed

最佳答案

我偶然找到了我的问题的答案。设置附加环境变量 PERL_CPANM_HOME 解决了该问题。

首先我们安装 local::lib

# Download and unpack the local::lib tarball from CPAN
wget https://cpan.metacpan.org/authors/id/H/HA/HAARG/local-lib-2.000024.tar.gz
tar xvf local-lib-2.000024.tar.gz
cd local-lib-2.000024
# Install local::lib in your home
perl Makefile.PL --bootstrap
make test && make install

现在我们使用 local::lib 来配置 cpanm 和 Perl,并设置两个附加环境变量:

eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
export PERL_CPANM_HOME=/tmp/cpanm_$USER
export MANPATH=$MANPATH:~/perl5/man

现在我们可以在集群的 HOME 目录中安装 Perl 模块。

cpanm HTML::PullParser

关于perl - 在主目录中安装 perl 模块时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46890932/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com