@@ -53,6 +53,23 @@ function copy_build_log() {
5353 fi
5454}
5555
56+ function safe_module_use {
57+ # add a given non-empty directory to $MODULEPATH if and only if it is not yet in
58+ directory=${1}
59+
60+ if [[ -z ${directory+x} ]]; then
61+ echo " safe_module_use: given directory unset or empty; not adding it to \$ MODULEPATH (${MODULEPATH} )"
62+ return
63+ fi
64+ if [[ " :${MODULEPATH} :" == * " :${directory} :" * ]]; then
65+ echo " safe_module_use: directory '${directory} ' is already in \$ MODULEPATH (${MODULEPATH} ); not adding it again"
66+ return
67+ else
68+ echo " safe_module_use: directory '${directory} ' is not yet in \$ MODULEPATH (${MODULEPATH} ); adding it"
69+ module use ${directory}
70+ fi
71+ }
72+
5673POSITIONAL_ARGS=()
5774
5875while [[ $# -gt 0 ]]; do
@@ -251,7 +268,9 @@ export EESSI_CVMFS_INSTALL=1
251268# NOTE 3, we have to set a default for EASYBUILD_INSTALLPATH here in cases the
252269# EESSI-extend module itself needs to be installed.
253270export EASYBUILD_INSTALLPATH=${EESSI_PREFIX} /software/${EESSI_OS_TYPE} /${EESSI_SOFTWARE_SUBDIR_OVERRIDE}
271+ echo " DEBUG: before loading EESSI-extend // EASYBUILD_INSTALLPATH='${EASYBUILD_INSTALLPATH} '"
254272source load_eessi_extend_module.sh ${EESSI_VERSION}
273+ echo " DEBUG: after loading EESSI-extend // EASYBUILD_INSTALLPATH='${EASYBUILD_INSTALLPATH} '"
255274
256275# Install full CUDA SDK and cu* libraries in host_injections
257276# Hardcode this for now, see if it works
@@ -305,7 +324,10 @@ if [[ "${EESSI_CVMFS_REPO}" == /cvmfs/dev.eessi.io ]]; then
305324 module use /cvmfs/software.eessi.io/versions/$EESSI_VERSION /software/${EESSI_OS_TYPE} /${EESSI_SOFTWARE_SUBDIR_OVERRIDE} /modules/all
306325fi
307326
308- module use $EASYBUILD_INSTALLPATH /modules/all
327+ echo " DEBUG: adding path '$EASYBUILD_INSTALLPATH /modules/all' to MODULEPATH='${MODULEPATH} '"
328+ # module use $EASYBUILD_INSTALLPATH/modules/all
329+ safe_module_use $EASYBUILD_INSTALLPATH /modules/all
330+ echo " DEBUG: after adding module path // MODULEPATH='${MODULEPATH} '"
309331
310332if [[ -z ${MODULEPATH} ]]; then
311333 fatal_error " Failed to set up \$ MODULEPATH?!"
@@ -373,8 +395,10 @@ else
373395 done
374396fi
375397
398+ echo " DEBUG: before creating/updating lmod config files // EASYBUILD_INSTALLPATH='${EASYBUILD_INSTALLPATH} '"
376399export LMOD_CONFIG_DIR=" ${EASYBUILD_INSTALLPATH} /.lmod"
377400lmod_rc_file=" $LMOD_CONFIG_DIR /lmodrc.lua"
401+ echo " DEBUG: lmod_rc_file='${lmod_rc_file} '"
378402if [[ ! -z ${EESSI_ACCELERATOR_TARGET} ]]; then
379403 # EESSI_ACCELERATOR_TARGET is set, so let's remove the accelerator path from $lmod_rc_file
380404 lmod_rc_file=$( echo ${lmod_rc_file} | sed " s@/accel/${EESSI_ACCELERATOR_TARGET} @@" )
0 commit comments