Skip to content

`apptainer run` by default sources user's `.bashrc`, which can override container's environment

Reproducer:

Add the following lines to the end of your .bashrc:

echo "sourced user bashrc"
export LD_LIBRARY_PATH="environment var overridden!!"

Then run the base container, latest tag:

apptainer pull docker://codecr.jlab.org/hallb/clas12/container-forge/base:latest
apptainer run base_latest.sif

which outputs:

sourced user bashrc
Apptainer> echo $LD_LIBRARY_PATH
environment var overridden!!"

We don't want this to happen, since many of our users have set such environment variables in their shell's rc files. We expect to see instead:

Apptainer> echo $LD_LIBRARY_PATH
/usr/local/lib:/.singularity.d/libs

(or whatever the current $LD_LIBRARY_PATH is set to in the image build)