cea-hpc / modules

Environment Modules: provides dynamic modification of a user's environment
http://modules.sourceforge.net/
GNU General Public License v2.0
668 stars 102 forks source link

Tags set through prereq not updated on loaded secondary requirement #459

Closed xdelaruelle closed 2 years ago

xdelaruelle commented 2 years ago

On version 5.1.0, when setting tags through a prereq command defining a list of requirements (two or more), the tags are not set on already loaded or loading alternative requirements (other than the first one).

Issue can be demonstrated when loading the additional requirement when dependent module is already loaded. In this situation, the reload of the dependent module should update the tags set on the loading requirement:

$ ml show mod
-------------------------------------------------------------------
/path/to/modulefiles/mod/1.0:

prereq          --tag=foo foo/1.0 bar/1.0
-------------------------------------------------------------------
$ ml mod
Loading mod/1.0
  Loading requirement: foo/1.0
$ ml bar/1.0
Loading bar/1.0
  Unloading dependent: mod/1.0
  Reloading dependent: mod/1.0
$ ml
Currently Loaded Modulefiles:
 1) foo/1.0 <foo>   2) bar/1.0   3) mod/1.0  

Key:
auto-loaded  <module-tag>  

When more than one requirement are already loaded then we try to load the dependent module, this module only updates the tags on the first dependent module in list:

$ ml purge
$ ml foo bar
$ ml
Currently Loaded Modulefiles:
 1) foo/1.0   2) bar/1.0  
$ ml mod
$ ml
Currently Loaded Modulefiles:
 1) foo/1.0 <foo>   2) bar/1.0   3) mod/1.0  

Key:
<module-tag>