Hello Roger,
I would say this is the right behaviour. If you want Modules to unset your variables when unloading the module, you should not use:
if { [ module-info mode load] } {
....
I would simply rewrite your module like this:
#%Module1.0#####################################################################
##
## GCC modulefile
##
proc ModulesHelp { } {
global version
puts stderr "\tSets up environment for GCC v$version."
}
module-whatis "sets up environment for GCC v13.3.0"
# for Tcl script use only
set version 13.3.0
set root /usr/local
conflict gcc
prepend-path INFOPATH $root/share/info
setenv LD_LIBRARY_PATH $root/gcc13
prepend-path MANPATH $root/share/man
prepend-path PATH $root/bin/
setenv GCC $root/bin/gcc13
if { [ module-info mode load] } {
file link -symbolic /home/rmason/bin/gcc $root/bin/gcc13
file link -symbolic /home/rmason/bin/g++ $root/bin/g++13;
file link -symbolic /home/rmason/bin/gfortran $root/bin/gfortran13; }
if { [ module-info mode ] == "unload" || [ module-info mode ] == "remove" } {
exec rm /home/rmason/bin/gcc; #
exec rm /home/rmason/bin/g++; #
exec rm /home/rmason/bin/gfortran; # }
Best regards,
Laurent
-----Message d'origine-----
De : Roger Mason via Modules-interest <mod...@li...>
Envoyé : vendredi 17 octobre 2025 14:10
À : mod...@li...
Cc : Roger Mason <rm...@mu...>
Objet : [Modules] envars not unset when unloading
Hello,
When unloading this modulefile the envars it sets are not unset:
#%Module1.0#####################################################################
##
## GCC modulefile
##
proc ModulesHelp { } {
global version
puts stderr "\tSets up environment for GCC v$version."
}
module-whatis "sets up environment for GCC v13.3.0"
# for Tcl script use only
set version 13.3.0
set root /usr/local
conflict gcc
if { [ module-info mode load] } {
prepend-path INFOPATH $root/share/info
setenv LD_LIBRARY_PATH $root/gcc13
prepend-path MANPATH $root/share/man
prepend-path PATH $root/bin/
setenv GCC $root/bin/gcc13
file link -symbolic /home/rmason/bin/gcc $root/bin/gcc13
file link -symbolic /home/rmason/bin/g++ $root/bin/g++13;
file link -symbolic /home/rmason/bin/gfortran $root/bin/gfortran13; }
if { [ module-info mode ] == "unload" || [ module-info mode ] == "remove" } {
exec rm /home/rmason/bin/gcc; #
exec rm /home/rmason/bin/g++; #
exec rm /home/rmason/bin/gfortran; # }
Session transcript:
rmason echo $LD_LIBRARY_PATH
rmason
rmason module load gcc/13.3.0
rmason echo $LD_LIBRARY_PATH
/usr/local/gcc13
module unload gcc/13.3.0
rmason echo $LD_LIBRARY_PATH
/usr/local/gcc13
I am running version modules-5.6.0 installed on FreeBSD-13.5 using the binary package system.
Thanks for nay help.
Roger
_______________________________________________
Modules-interest mailing list
Mod...@li...
https://lists.sourceforge.net/lists/listinfo/modules-interest
|