@@ -487,10 +487,7 @@ def module_wrapper_exists(self, mod_name, modulerc_fn='.modulerc', mod_wrapper_r
487487 """
488488 Determine whether a module wrapper with specified name exists.
489489 Only .modulerc file in Tcl syntax is considered here.
490- DEPRECATED. Use exists()
491490 """
492- self .log .deprecated ('module_wrapper_exists is unreliable and should no longer be used. ' +
493- 'Use exists instead to check for an existing module or alias.' , '5.0' )
494491
495492 if mod_wrapper_regex_template is None :
496493 mod_wrapper_regex_template = "^[ ]*module-version (?P<wrapped_mod>[^ ]*) %s$"
@@ -590,6 +587,19 @@ def mod_exists_via_show(mod_name):
590587 self .log .debug ("checking whether hidden module %s exists via 'show'..." % mod_name )
591588 mod_exists = mod_exists_via_show (mod_name )
592589
590+ # if no module file was found, check whether specified module name can be a 'wrapper' module...
591+ # this fallback mechanism is important when using a hierarchical module naming scheme,
592+ # where "full" module names (like Core/Java/11) are used to check whether modules exist already;
593+ # Lmod will report module wrappers as non-existent when full module name is used,
594+ # see https://github.com/TACC/Lmod/issues/446
595+ if not mod_exists :
596+ self .log .debug ("Module %s not found via module avail/show, checking whether it is a wrapper" , mod_name )
597+ wrapped_mod = self .module_wrapper_exists (mod_name )
598+ if wrapped_mod is not None :
599+ # module wrapper only really exists if the wrapped module file is also available
600+ mod_exists = wrapped_mod in avail_mod_names or mod_exists_via_show (wrapped_mod )
601+ self .log .debug ("Result for existence check of wrapped module %s: %s" , wrapped_mod , mod_exists )
602+
593603 self .log .debug ("Result for existence check of %s module: %s" , mod_name , mod_exists )
594604
595605 mods_exist .append (mod_exists )
@@ -1407,7 +1417,7 @@ def prepend_module_path(self, path, set_mod_paths=True, priority=None):
14071417 def module_wrapper_exists (self , mod_name ):
14081418 """
14091419 Determine whether a module wrapper with specified name exists.
1410- DEPRECATED. Use exists()
1420+ First check for wrapper defined in .modulerc.lua, fall back to also checking .modulerc (Tcl syntax).
14111421 """
14121422 res = None
14131423
0 commit comments