From fcf37f8b44a0ca964b07a091749cd698d6e71569 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 28 Apr 2021 16:52:58 +0000 Subject: [PATCH 1/2] Pmodule modulefile: remove Pmodules bin dir from PATH in some cases it might happen that we have a Pmodules bin directory in PATH. This has to be removed if we load a Pmodule module. (cherry picked from commit d23fdf930a523796de8562dfb91a76cccd9b6ef1) --- Pmodules/modulefile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Pmodules/modulefile b/Pmodules/modulefile index 65aa4c1..2a9311d 100644 --- a/Pmodules/modulefile +++ b/Pmodules/modulefile @@ -8,3 +8,15 @@ module-maintainer "Achim Gsell " module-help " Pmodules are a hierarchical module environment based on Environment Modules. " + +# +# It might be that '${PMODULES_ROOT}/Tools/Pmodules/VERSION' is in PATH. +# Why? With older version the PATH might have been set without loading +# a module. +# +if { [module-info mode load] } { + set PATH ":$::env(PATH):" + if { [regexp -- {.*:(.*/Pmodules/[^:]*):} $PATH -> str] } { + remove-path PATH $str + } +} From 2faf42a4e046250b936f9ac2dcd9f664b5df5a17 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 6 May 2021 07:27:28 +0000 Subject: [PATCH 2/2] modulefile: bugfix in modifying PATH (cherry picked from commit d25663a32e7d9f3453be59fb94bd971d72ea2b61) --- Pmodules/modulefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Pmodules/modulefile b/Pmodules/modulefile index 2a9311d..1893fdb 100644 --- a/Pmodules/modulefile +++ b/Pmodules/modulefile @@ -17,6 +17,8 @@ Pmodules are a hierarchical module environment based on Environment Modules. if { [module-info mode load] } { set PATH ":$::env(PATH):" if { [regexp -- {.*:(.*/Pmodules/[^:]*):} $PATH -> str] } { - remove-path PATH $str + if { [string compare $str $PREFIX/bin] != 0 } { + remove-path PATH $str + } } }