1

So I am trying to have module files dynamically load/unload when you load one. I am trying to do this in a way so that I can unload conflicting modules (instead of just using the conflict variable as it just throws an error)

However, when I call module load on one file that tries to unload another... the second one is loaded instead of unloaded. Example is below:

test1 Modulefile:

#%Module1.0
##
## Testing
##
if { [module-info mode load] && [is-loaded test2] } {
        puts stderr "Unloading test2 (From test1)"
        module unload test2
}

test2 Modulefile:

#%Module1.0
##
## Test2
##
if { [module-info mode load] } {
        puts stderr "Loading test2\n"
}

if { [module-info mode remove] } {
        puts stderr "Unloading test2\n"
}

Output when I try to load test1 while test2 is loaded:

root@host:/usr/local/modules# module load test1
Unloading test2 (From test1)
Loading test2

module --version output:

VERSION=3.2.10
DATE=2012-12-21

AUTOLOADPATH=undef
BASEPREFIX="/usr"
BEGINENV=99
CACHE_AVAIL=undef
DEF_COLLATE_BY_NUMBER=undef
DOT_EXT=""
EVAL_ALIAS=1
HAS_BOURNE_FUNCS=1
HAS_BOURNE_ALIAS=1
HAS_TCLXLIBS=undef
HAS_X11LIBS=1
LMSPLIT_SIZE=1000
MODULEPATH="/usr/share/modules/modulefiles"
MODULES_INIT_DIR="/usr/Modules/3.2.10/init"
PREFIX="/usr/Modules/3.2.10"
TCL_VERSION="8.6"
TCL_PATCH_LEVEL="8.6.1"
TMP_DIR="/tmp"
USE_FREE=undef
VERSION_MAGIC=1
VERSIONPATH="/usr/share/modules/versions"
WANTS_VERSIONING=1
WITH_DEBUG_INFO=undef

Does anyone know why or how I can fix this? Is there another command that I can put in the Modulefile that unloads another module? Or is there an better alternative to using Modules?

Thanks in advanced for reading and helping!

Matthew
  • 138
  • 2
  • 9

1 Answers1

0

The issue you describe is coming from a bug affecting Modules version <= 3.2.10. Newer Modules version (> 3.2.10) or up-to-date "environment-modules" package on RedHat-like Linux distribution have fixed this issue:

For instance on a recent Fedora system, excepted behavior is obtained:

$ module -V
Modules Release 4.1.3 (2018-06-18)
$ module load test2
Loading test2

$ module list
Currently Loaded Modulefiles:
 1) test2
$ module load test1
Unloading test2 (From test1)
Unloading test2

$ module list
Currently Loaded Modulefiles:
 1) test1