cea-hpc / modules

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

Error when switching between modules version (`--enable-versioning` option) #531

Closed xdelaruelle closed 3 months ago

xdelaruelle commented 3 months ago

Modulefiles generated when --enable-versioning installation option is set do not allow to switch between the different installed version of Modules:

$ ml 5.3.1
Loading modules
  ERROR: Conflicting 5.3.1 is loading

Loading 5.3.1
  ERROR: Load of requirement modules failed
xdelaruelle commented 3 months ago

Issue comes from the use of module unload command within the generated versions modulefiles. Since v4.2, use of module unload indicates a conflict toward module targeted for unload.

Adding the --not-req option to these module unload commands helps to not define a conflict toward these modules to unload. The --not-req option has been introduced on Modules 4.7.

Existing versions modulefiles for Modules version above 4.6 should be updated to add the --not-req option to the module unload commands. The following shell script should help to fix these modulefiles (replace /usr/local/Modules/versions by the location where the versions modulefiles are located on your setup):

for i in /usr/local/Modules/versions/*; do
    version=$(basename "$i")
    version=$i
    major=${version:0:1}
    minor=${version:2:1}
    if [[ "$major" -gt 4 || ("$major" -eq 4 && "$minor" -gt 6) ]]; then
        sed -i "s|module unload|module unload --not-req|" "$i"
    fi
done
xdelaruelle commented 3 months ago

Fixed by 58476f8