为什么 PERL5LIB 环境变量在 `source $PERLBREW_ROOT/etc/bashrc` 之后消失了?
Why PERL5LIB env variable is disappeared after `source $PERLBREW_ROOT/etc/bashrc`?
在我的Dockerfile
中我有下一个命令:
FROM perl:5.30.3-buster
...
RUN env && source $PERLBREW_ROOT/etc/bashrc && env && carton install
当执行 source $PERLBREW_ROOT/etc/bashrc
时,PERL5LIB
消失并且 carton
找不到 PERL5LIB
路径
指示的库
命令输出:
Step 18/22 : RUN env && source $PERLBREW_ROOT/etc/bashrc && env && carton install
---> Running in 358cb3aa042e
HOSTNAME=358cb3aa042e
PERL_VERSION=5.34.1
PERLBREW_HOME=/opt/perlbrew/home
PWD=/
HOME=/root
PERL5LIB=/opt/proj/lib:/opt/proj/local/lib/perl5:
SHLVL=1
PATH=/opt/perlbrew/bin:/opt/proj/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PERLBREW_ROOT=/opt/perlbrew
_=/usr/bin/env
HOSTNAME=358cb3aa042e
PERL_VERSION=5.34.1
PERLBREW_PATH=/opt/perlbrew/bin:/opt/perlbrew/perls/perl-5.34.1/bin
PERLBREW_HOME=/opt/perlbrew/home
PERLBREW_SHELLRC_VERSION=0.94
PWD=/
MANPATH=/opt/perlbrew/perls/perl-5.34.1/man:
PERLBREW_PERL=perl-5.34.1
HOME=/root
PERLBREW_VERSION=0.94
SHLVL=1
PATH=/opt/perlbrew/bin:/opt/perlbrew/perls/perl-5.34.1/bin:/opt/proj/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PERLBREW_ROOT=/opt/perlbrew
PERLBREW_MANPATH=/opt/perlbrew/perls/perl-5.34.1/man
_=/usr/bin/env
但是 运行 主机系统上的相同命令不会擦除 PERL5LIB
:
(env | grep PERL) && source ~/perl5/perlbrew/etc/bashrc && (env | grep PERL)
PERLBREW_PATH=/home/kes/perl5/perlbrew/bin:/home/kes/perl5/perlbrew/perls/perl-5.30.3/bin
PERLBREW_HOME=/home/kes/.perlbrew
PERLBREW_SHELLRC_VERSION=0.89
PERLBREW_PERL=perl-5.30.3
PERLBREW=command perlbrew
PERLBREW_VERSION=0.89
PERL5LIB=xxx
PERLBREW_ROOT=/home/kes/perl5/perlbrew
PERLBREW_MANPATH=/home/kes/perl5/perlbrew/perls/perl-5.30.3/man
PERLBREW_PATH=/home/kes/perl5/perlbrew/bin:/home/kes/perl5/perlbrew/perls/perl-5.30.3/bin
PERLBREW_HOME=/home/kes/.perlbrew
PERLBREW_SHELLRC_VERSION=0.89
PERLBREW_PERL=perl-5.30.3
PERLBREW=command perlbrew
PERLBREW_VERSION=0.89
PERL5LIB=xxx
PERLBREW_ROOT=/home/kes/perl5/perlbrew
PERLBREW_MANPATH=/home/kes/perl5/perlbrew/perls/perl-5.30.3/man
请告诉我,在构建容器时 运行 来自 Docker
文件的命令有什么问题?
谢谢@ikegami
${PERLBREW_HOME:-}/init
unset
。当您在 perls 之间切换并且不希望它们的库相互混合时,这个 unset
是必需的。
例如,您使用的是 perl-5.24 并已将库安装到其 PERL5LIB
中,然后您切换到 perl-5.28,但 PERL5LIB
仍然指向由不同版本的 perl 安装的模块。这可能会导致核心转储。
在我的Dockerfile
中我有下一个命令:
FROM perl:5.30.3-buster
...
RUN env && source $PERLBREW_ROOT/etc/bashrc && env && carton install
当执行 source $PERLBREW_ROOT/etc/bashrc
时,PERL5LIB
消失并且 carton
找不到 PERL5LIB
路径
命令输出:
Step 18/22 : RUN env && source $PERLBREW_ROOT/etc/bashrc && env && carton install
---> Running in 358cb3aa042e
HOSTNAME=358cb3aa042e
PERL_VERSION=5.34.1
PERLBREW_HOME=/opt/perlbrew/home
PWD=/
HOME=/root
PERL5LIB=/opt/proj/lib:/opt/proj/local/lib/perl5:
SHLVL=1
PATH=/opt/perlbrew/bin:/opt/proj/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PERLBREW_ROOT=/opt/perlbrew
_=/usr/bin/env
HOSTNAME=358cb3aa042e
PERL_VERSION=5.34.1
PERLBREW_PATH=/opt/perlbrew/bin:/opt/perlbrew/perls/perl-5.34.1/bin
PERLBREW_HOME=/opt/perlbrew/home
PERLBREW_SHELLRC_VERSION=0.94
PWD=/
MANPATH=/opt/perlbrew/perls/perl-5.34.1/man:
PERLBREW_PERL=perl-5.34.1
HOME=/root
PERLBREW_VERSION=0.94
SHLVL=1
PATH=/opt/perlbrew/bin:/opt/perlbrew/perls/perl-5.34.1/bin:/opt/proj/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PERLBREW_ROOT=/opt/perlbrew
PERLBREW_MANPATH=/opt/perlbrew/perls/perl-5.34.1/man
_=/usr/bin/env
但是 运行 主机系统上的相同命令不会擦除 PERL5LIB
:
(env | grep PERL) && source ~/perl5/perlbrew/etc/bashrc && (env | grep PERL)
PERLBREW_PATH=/home/kes/perl5/perlbrew/bin:/home/kes/perl5/perlbrew/perls/perl-5.30.3/bin
PERLBREW_HOME=/home/kes/.perlbrew
PERLBREW_SHELLRC_VERSION=0.89
PERLBREW_PERL=perl-5.30.3
PERLBREW=command perlbrew
PERLBREW_VERSION=0.89
PERL5LIB=xxx
PERLBREW_ROOT=/home/kes/perl5/perlbrew
PERLBREW_MANPATH=/home/kes/perl5/perlbrew/perls/perl-5.30.3/man
PERLBREW_PATH=/home/kes/perl5/perlbrew/bin:/home/kes/perl5/perlbrew/perls/perl-5.30.3/bin
PERLBREW_HOME=/home/kes/.perlbrew
PERLBREW_SHELLRC_VERSION=0.89
PERLBREW_PERL=perl-5.30.3
PERLBREW=command perlbrew
PERLBREW_VERSION=0.89
PERL5LIB=xxx
PERLBREW_ROOT=/home/kes/perl5/perlbrew
PERLBREW_MANPATH=/home/kes/perl5/perlbrew/perls/perl-5.30.3/man
请告诉我,在构建容器时 运行 来自 Docker
文件的命令有什么问题?
谢谢@ikegami
${PERLBREW_HOME:-}/init
unset
。当您在 perls 之间切换并且不希望它们的库相互混合时,这个 unset
是必需的。
例如,您使用的是 perl-5.24 并已将库安装到其 PERL5LIB
中,然后您切换到 perl-5.28,但 PERL5LIB
仍然指向由不同版本的 perl 安装的模块。这可能会导致核心转储。