diff --git a/NEWS.rst b/NEWS.rst index 1024483e5..7070ad5f6 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -73,6 +73,10 @@ Modules 5.8.0 (not yet released) commands to support modulerc files written for Lmod. They are aliases of :mfcmd:`module-forbid` and :mfcmd:`module-hide` with ``--regexp`` option set. +* Fix error raised when the :mconfig:`implicit_requirement` configuration + option is changed with the :subcmd:`config` sub-command from an + initialization rc file or a sourced modulefile. (fix issue #740 with + contribution from Achim Gsell) .. _5.7 release notes: diff --git a/tcl/mfcmd.tcl b/tcl/mfcmd.tcl index 9f54b19a1..a408ae11c 100644 --- a/tcl/mfcmd.tcl +++ b/tcl/mfcmd.tcl @@ -2705,7 +2705,9 @@ proc module {command args} { knerrorModule 0 "Command '$command' not supported" } # no requirement should be recorded this module load/unload/switch cmd - if {$not_req || ![getConf implicit_requirement]} { + # test made once as config sub-command may change implicit_requirement + set inhibit_req [expr {$not_req || ![getConf implicit_requirement]}] + if {$inhibit_req} { lappendState inhibit_req_record [currentState evalid] } @@ -2718,7 +2720,7 @@ proc module {command args} { lpopState commandname lpopState always_read_full_file - if {$not_req || ![getConf implicit_requirement]} { + if {$inhibit_req} { lpopState inhibit_req_record } diff --git a/testsuite/modules.50-cmds/430-implicit-req.exp b/testsuite/modules.50-cmds/430-implicit-req.exp index e42d8b580..146b0f573 100644 --- a/testsuite/modules.50-cmds/430-implicit-req.exp +++ b/testsuite/modules.50-cmds/430-implicit-req.exp @@ -497,6 +497,27 @@ unsetenv_var __MODULES_LMTAG unsetenv_loaded_module +# +# change implicit_requirement with config sub-command from sourced file +# + +set modfile [file join [pwd] impreqconfig.mod] +set fid [open $modfile w] +puts $fid {#%Module +module config implicit_requirement $env(TESTSUITE_IMPLICIT_REQ)} +close $fid + +foreach {cur new} {1 0 0 1 1 1 0 0} { + setenv_var MODULES_IMPLICIT_REQUIREMENT $cur + setenv_var TESTSUITE_IMPLICIT_REQ $new + set ans [list [list set MODULES_IMPLICIT_REQUIREMENT $new]] + testouterr_cmd sh "source $modfile" $ans {} +} + +unsetenv_var TESTSUITE_IMPLICIT_REQ +file delete $modfile + + # # Cleanup #