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

Log module command cookbook breaks modules initialization #453

Closed eburgueno closed 2 years ago

eburgueno commented 2 years ago

Describe the bug

Log module command cookbook breaks modules initialization. Appears to be related to uasked. I suspect the root cause here is that cmdModuleSource does not include a uasked argument like cmdModuleLoad does.

To Reproduce

Steps to reproduce the behavior (this is a minimal example):

$ cat /software/EnvironmentModules/5.0.1/etc/siteconfig.tcl
# SITECONFIG.TCL, site-specific configuration script for Modules
#
# This Tcl script enables to supersede any global variable or procedure
# definition of modulecmd.tcl. See 'Modulecmd startup' section in module(1)
# manpage for detailed information.
##########################################################################
proc logTest {cmdstring code result op} {
  set mode [currentState mode]
  if { $mode eq {load} } {
    upvar 1 uasked uasked
    puts stderr "debug logTest: cmdstring=$cmdstring"
    puts stderr "debug logTest: mode=$mode"
    puts stderr "debug logTest: uasked=$uasked"
 }
}
trace add execution execute-modulefile leave logTest

$ source /software/EnvironmentModules/5.0.1/init/bash
debug logTest: cmdstring=execute-modulefile /software/EnvironmentModules/5.0.1/etc/initrc /software/EnvironmentModules/5.0.1/etc/initrc /software/EnvironmentModules/5.0.1/etc/initrc /software/EnvironmentModules/5.0.1/etc/initrc 0 0
debug logTest: mode=load
ERROR: 0
      while executing
  "execute-modulefile $absfpath $absfpath $absfpath $absfpath 0 0"
      (procedure "cmdModuleSource" line 10)
      invoked from within
  "cmdModuleSource load /software/EnvironmentModules/5.0.1/etc/initrc"
      (procedure "cmdModuleAutoinit" line 64)
      invoked from within
  "cmdModuleAutoinit"
      (procedure "module" line 333)
      invoked from within
  "{*}$execcmdlist"
  Please report this issue at https://github.com/cea-hpc/modules/issues

Expected behavior

uasked is set to whatever values identify that a modulefile is auto-loaded or not, or the cookbook provides a more explicit command name for trace than execute-modulefile.

xdelaruelle commented 2 years ago

Many thank for your report and analysis. I am fixing this right away.

eburgueno commented 2 years ago

Thank you! I can confirm that fixes it :)