You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Update order of entries in path environment variable #595
Currently when a prepend-path, append-path or module use target a path entry that is already defined in the environment variable, its value is not updated.
A configuration option may be introduced to update the order of entries, for instance on a prepend-path to move the path entry at the first position.
This is the behavior used by default on Lmod. And Lmod has LMOD_TMOD_PATH_RULE to set the behavior like on Modules.
I took a look at this issue. I noticed the following: In the getReferenceCountArray procedure, the counter is always 1 - even if, for example, a directory appears multiple times in MODULEPATH. In the for loop refcount($elt) is never set, so count will be always set to 1:
foreach elt $eltlist {
# no reference counter, means value has been set once
if {![info exists refcount($elt)]} {
set count 1
# bad reference counter value is ignored
} elseif {![string is digit -strict $refcount($elt)] ||\
$refcount($elt) < 1} {
reportDebug "Reference counter value for '$elt' in '$sharevar' is\
erroneous ($refcount($elt))"
set count 1
} else {
set count $refcount($elt)
}
set countarr($elt) $count
}
I took a look at this issue. I noticed the following: In the getReferenceCountArray procedure, the counter is always 1 - even if, for example, a directory appears multiple times in MODULEPATH. In the for loop refcount($elt) is never set, so count will be always set to 1:
This is true if the reference counter variable (__MODULES_SHARE_<ENVVAR>) is not set . This variable is updated if an entry is added in duplicate mode.
I created a PR for this issue. This PR adds a config option lmod_path_rule (not sure whether this is a good name). Should this be applied for all path manipulations or MODULEPATH only? For now I implemented it in proc add-path for all paths.
Activity
gsell commentedon Oct 27, 2025
I took a look at this issue. I noticed the following: In the
getReferenceCountArrayprocedure, the counter is always1- even if, for example, a directory appears multiple times inMODULEPATH. In the for looprefcount($elt)is never set, socountwill be always set to1:xdelaruelle commentedon Oct 27, 2025
This is true if the reference counter variable (
__MODULES_SHARE_<ENVVAR>) is not set . This variable is updated if an entry is added in duplicate mode.gsell commentedon Oct 29, 2025
Ok, understood!
gsell commentedon Oct 29, 2025
I created a PR for this issue. This PR adds a config option
lmod_path_rule(not sure whether this is a good name). Should this be applied for all path manipulations orMODULEPATHonly? For now I implemented it inproc add-pathfor all paths.Tests for this change are still missing.
xdelaruelle commentedon Nov 2, 2025
Good candidates for option name:
update_path_order,path_entry_reordergsell commentedon Nov 21, 2025
What is the correct behaviour in the following (edge-)case:
?
PATHVAR == {a:a:b:a}(precedence of duplicates) orPATHVAR == {b:a}xdelaruelle commentedon Nov 21, 2025
PATHVAR == {b:a}: last append-path call is not made with--duplicatesoption, so all occurences are merged and moved to the end of the list.Add path_entry_reorder configuration option
Add path_entry_reorder configuration option