From 45f6096f2f207137451708e34288e040caae89aa Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Thu, 3 Dec 2026 18:54:48 +0100 Subject: [PATCH] Fix indesym avail on symbol in dir without visible mod When symbolic versions are reported as independent entries (indesym element in avail or spider output configuration), a symbolic version is recorded in the content of its parent directory. If this directory only holds hidden modules, it is not part of the found elements and getModules raised an error when reading its properties. Such symbolic version is now withdrawn from result, like done when symbolic versions are reported along their target. Shell completion scripts query available modules with indesym element, thus module name completion was broken on modulepaths with such directory. Assisted-by: Claude:claude-fable-5-2 Signed-off-by: Xavier Delaruelle --- NEWS.rst | 5 +++++ tcl/modfind.tcl.in | 7 +++++++ testsuite/modules.70-maint/360-avail_output.exp | 5 +++++ testsuite/modules.70-maint/362-spider_output.exp | 5 +++++ 4 files changed, 22 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index 4fadf121f..e11a0e154 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -133,6 +133,11 @@ Modules 5.8.0 (not yet released) value. (fix issue #712) * Doc: add :ref:`subcmd-alias` design notes. * Doc: add :ref:`spack-like-sub-command-names` cookbook recipe. +* Fix :subcmd:`avail` and :subcmd:`spider` sub-commands error when symbolic + versions are reported as independent entries (``indesym`` element set in + output configuration) and a symbolic version is defined in a directory + that only contains hidden modules. Shell completion of module names was + also affected, as completion scripts rely on this output element. .. _5.7 release notes: diff --git a/tcl/modfind.tcl.in b/tcl/modfind.tcl.in index d4e6f4f63..baac3c114 100644 --- a/tcl/modfind.tcl.in +++ b/tcl/modfind.tcl.in @@ -3725,6 +3725,13 @@ proc getModules {dir {mod {}} {fetch_mtime 0} {search {}} {filter {}}} { # skip adding element to directory content if in error } elseif {[info exists err_list($elt)]} { set direlt . + # withdraw version reported independently if the directory it is + # defined in is not found (as it holds no visible module), like when + # version is reported along its target + } elseif {$elt_type eq {version} && [set pardir [file dirname\ + $elt]] ne {.} && ![info exists found_list($pardir)]} { + unset mod_list($elt) + set direlt . } else { set direlt $elt } diff --git a/testsuite/modules.70-maint/360-avail_output.exp b/testsuite/modules.70-maint/360-avail_output.exp index 4264a0bdf..4a95c2937 100644 --- a/testsuite/modules.70-maint/360-avail_output.exp +++ b/testsuite/modules.70-maint/360-avail_output.exp @@ -255,6 +255,11 @@ setenv_var MODULES_AVAIL_TERSE_OUTPUT key:indesym testouterr_cmd sh {avail -t foo/bar} OK "foo/bar" testouterr_cmd sh {avail -t foo/1.0} OK "foo/1.0" unsetenv_var MODULES_AVAIL_TERSE_OUTPUT +# symbolic version defined in a directory that only holds hidden modules +setenv_path_var MODULEPATH $modpath +testouterr_cmd sh {avail -t -o indesym loc_rc010/subdir} OK {} +testouterr_cmd sh {avail -t -o indesym loc_rc010/subdir/default} OK {} +testouterr_cmd sh {avail -t -o indesym loc_rc010/2} OK loc_rc010/2.0 setenv_path_var MODULEPATH $modpath.2 testouterr_cmd_re sh {avail -w 120 -o modulepath:key:dirwsym:indesym hide3/sub2} OK "$modlin $modpathre.2 $modlin\nhide3/sub2/4.0 hide3/sub2/5.0 hide3/sub2/default hide3/sub2/new hide3/sub2/sym" testouterr_cmd_re sh {avail -w 120 -o modulepath:key:indesym hide3/sub2} OK "$modlin $modpathre.2 $modlin\nhide3/sub2/4.0 hide3/sub2/5.0 hide3/sub2/default hide3/sub2/new hide3/sub2/sym" diff --git a/testsuite/modules.70-maint/362-spider_output.exp b/testsuite/modules.70-maint/362-spider_output.exp index f0e7ba98f..eb4109866 100644 --- a/testsuite/modules.70-maint/362-spider_output.exp +++ b/testsuite/modules.70-maint/362-spider_output.exp @@ -175,6 +175,11 @@ setenv_var MODULES_SPIDER_TERSE_OUTPUT key:indesym testouterr_cmd sh {spider -t foo/bar} OK "foo/bar" testouterr_cmd sh {spider -t foo/1.0} OK "foo/1.0" unsetenv_var MODULES_SPIDER_TERSE_OUTPUT +# symbolic version defined in a directory that only holds hidden modules +setenv_path_var MODULEPATH $modpath +testouterr_cmd sh {spider -t -o indesym loc_rc010/subdir} OK {} +testouterr_cmd sh {spider -t -o indesym loc_rc010/subdir/default} OK {} +testouterr_cmd sh {spider -t -o indesym loc_rc010/2} OK loc_rc010/2.0 setenv_path_var MODULEPATH $modpath.2 testouterr_cmd_re sh {spider -w 120 -o modulepath:key:dirwsym:indesym hide3/sub2} OK "$modlin $modpathre.2 $modlin\nhide3/sub2/4.0 hide3/sub2/5.0 hide3/sub2/default hide3/sub2/new hide3/sub2/sym" testouterr_cmd_re sh {spider -w 120 -o modulepath:key:indesym hide3/sub2} OK "$modlin $modpathre.2 $modlin\nhide3/sub2/4.0 hide3/sub2/5.0 hide3/sub2/default hide3/sub2/new hide3/sub2/sym"