我想在我的项目中使用快速cpm模块安装程序而不是 cpanm。
我还使用perlbrew安装目标 perl 版本。
根据cpm选项的文档-g
将模块安装到当前的@INC
如何在 Dockerfile 中强制 perlbrew 更改 @INC?
以下是我的 Dockerfile 的一部分
RUN perl -le 'print for @INC' && \
perlbrew switch perl-5.31.0 && \
perl -le 'print for @INC' && \
cpm install -gv CGI && \
perlbrew list-modules
当我构建 Dockerfile 输出时perl -le 'print for @INC'
两次都相同:
/etc/perl
/usr/local/lib/x86_64-linux-gnu/perl/5.22.1
/usr/local/share/perl/5.22.1
/usr/lib/x86_64-linux-gnu/perl5/5.22
/usr/share/perl5
/usr/lib/x86_64-linux-gnu/perl/5.22
/usr/share/perl/5.22
/usr/local/lib/site_perl
/usr/lib/x86_64-linux-gnu/perl-base
但是,如果我手动执行相同的操作,结果是可以的:
$ docker run -it pavelsr/xxxhub
root@1a34ea34a3fb:/# perl -le 'print for @INC'
/etc/perl
/usr/local/lib/x86_64-linux-gnu/perl/5.22.1
/usr/local/share/perl/5.22.1
/usr/lib/x86_64-linux-gnu/perl5/5.22
/usr/share/perl5
/usr/lib/x86_64-linux-gnu/perl/5.22
/usr/share/perl/5.22
/usr/local/lib/site_perl
/usr/lib/x86_64-linux-gnu/perl-base
.
root@1a34ea34a3fb:/# perlbrew switch perl-5.31.0
A sub-shell is launched with perl-5.31.0 as the activated perl. Run 'exit' to finish it.
root@1a34ea34a3fb:/# perl -le 'print for @INC'
/usr/local/perlbrew/perls/perl-5.31.0/lib/site_perl/5.31.0/x86_64-linux
/usr/local/perlbrew/perls/perl-5.31.0/lib/site_perl/5.31.0
/usr/local/perlbrew/perls/perl-5.31.0/lib/5.31.0/x86_64-linux
/usr/local/perlbrew/perls/perl-5.31.0/lib/5.31.0
root@1a34ea34a3fb:/# cpm install -g CGI
DONE install HTML-Tagset-3.20
DONE install HTML-Parser-3.72
DONE install CGI-4.44
3 distributions installed.
root@1a34ea34a3fb:/# perlbrew list-modules
CGI
HTML::Parser
HTML::Tagset
Perl