Background
We use Lmod (Lua-based; https://lmod.readthedocs.io/) as our environment module system, rather than the traditionally Tmod (Tcl-based) system.
We also install the gcc-toolset SCLs (we're on Rocky 8), and we have scl-utils.x86_64 installed.
Issue
With Lmod installed, we'd expect:
$ echo "MODULESHOME=${MODULESHOME}"
MODULESHOME=/usr/share/lmod/lmod
but we get:
$ echo "MODULESHOME=${MODULESHOME}"
MODULESHOME=/usr/share/Modules
Troubleshooting
During shell startup process, /etc/profile.d/scl-init.sh sets and exports MODULESHOME unconditionally;
|
MODULESHOME=/usr/share/Modules |
|
export MODULESHOME |
|
|
|
if [ "${MODULEPATH:-}" = "" ]; then |
|
MODULEPATH=`sed -n 's/[ #].*$//; /./H; $ { x; s/^\n//; s/\n/:/g; p; }' ${MODULESHOME}/init/.modulespath` |
|
fi |
This overrides MODULESHOME already set while processing Lmod's /etc/profile.d/modules.sh (-> /etc/alternatives/modules.sh -> /usr/share/lmod/lmod/init/profile).
Suggestion / patch
I think scl-init.sh:
- should not hardcode
MODULESHOME,
- should not make assumptions about
MODULESHOME, and
- should not override
MODULESHOME, if already set
Here's a backward-compatible patch that I think address these requirements:
git diff -w
diff --git a/shell/scl-init.csh b/shell/scl-init.csh
index 45b22be..efc4695 100644
--- a/shell/scl-init.csh
+++ b/shell/scl-init.csh
@@ -1,6 +1,8 @@
alias scl 'source /etc/scl/func_scl.csh'
+if (! $?MODULESHOME ) then
setenv MODULESHOME /usr/share/Modules
+endif
if (! $?MODULEPATH ) then
setenv MODULEPATH `sed -n 's/[ #].*$//; /./H; $ { x; s/^\n//; s/\n/:/g; p; }' ${MODULESHOME}/init/.modulespath`
diff --git a/shell/scl-init.sh b/shell/scl-init.sh
index 6eeabea..373e00f 100644
--- a/shell/scl-init.sh
+++ b/shell/scl-init.sh
@@ -12,7 +12,7 @@ fi
shell=`/bin/basename \`/bin/ps -p $$ -ocomm=\``
[ "$shell" = "bash" ] && export -f scl # export -f works only in bash
-MODULESHOME=/usr/share/Modules
+MODULESHOME=${MODULESHOME:-/usr/share/Modules}
export MODULESHOME
if [ "${MODULEPATH:-}" = "" ]; then
Background
We use Lmod (Lua-based; https://lmod.readthedocs.io/) as our environment module system, rather than the traditionally Tmod (Tcl-based) system.
We also install the
gcc-toolsetSCLs (we're on Rocky 8), and we havescl-utils.x86_64installed.Issue
With Lmod installed, we'd expect:
but we get:
Troubleshooting
During shell startup process,
/etc/profile.d/scl-init.shsets and exportsMODULESHOMEunconditionally;scl-utils/shell/scl-init.sh
Lines 15 to 20 in 1b78a48
This overrides
MODULESHOMEalready set while processing Lmod's/etc/profile.d/modules.sh(->/etc/alternatives/modules.sh->/usr/share/lmod/lmod/init/profile).Suggestion / patch
I think
scl-init.sh:MODULESHOME,MODULESHOME, andMODULESHOME, if already setHere's a backward-compatible patch that I think address these requirements: