Skip to content

Fix initialization order in ModulesTool, tests and don't set $LMOD_REDIRECT='no'#5079

Open
Flamefire wants to merge 6 commits intoeasybuilders:developfrom
Flamefire:module-cmd-tests
Open

Fix initialization order in ModulesTool, tests and don't set $LMOD_REDIRECT='no'#5079
Flamefire wants to merge 6 commits intoeasybuilders:developfrom
Flamefire:module-cmd-tests

Conversation

@Flamefire
Copy link
Copy Markdown
Contributor

self.set_mod_paths(mod_paths) calls the modules command which isn't fully initialized at this point.
This isn't caught as we don't pass that parameter in any usage (so far)

So move that around.

Also the test_lmod_specific might (almost?) always be skipped because lmod is not in $PATH, but only in $LMOD_CMD
Additionally parts of the modules-specific tests can be run even if that modules tool is not available. So only skip what has to be skipped.

Finally revert #1755: $LMOD_REDIRECT only affects the module function which we do not use. So do not set that variable to "no" which makes working in the debug shell easier.

Before calling any module function `self.cmd  must be initialized and
verified.
So modify `$MODULEPATH` after those checks.
Also don't skip the LMod specific tests if `lmod` is not in `$PATH`
which it usually is not.
In `test_environment_modules_specific` we can verify the `module`
function even if EnvironmentModules is not installed by using the fake command.
@boegel boegel changed the title Fix initialization order in ModulesTool, tests and don't set $LMOD_REDIRECT='no' Fix initialization order in ModulesTool, tests and don't set $LMOD_REDIRECT='no' Apr 8, 2026
@boegel
Copy link
Copy Markdown
Member

boegel commented Apr 8, 2026

Finally revert #1755: $LMOD_REDIRECT only affects the module function which we do not use. So do not set that variable to "no" which makes working in the debug shell easier.

@Flamefire How sure are you about this?

I see being used in https://github.com/TACC/Lmod/blob/main/shells/Rc.lua for example, that seems beyond the module shell function to me...

I also don't see why keeping $LMOD_REDIRECT set to no would be problematic in any way, better be cautious with this?

@Flamefire
Copy link
Copy Markdown
Contributor Author

Reasonably sure. The code you quote is actually a case for reverting that:

It seems to handle "echo" commands in the module file:

  • LMOD_REDIRECT=no: print directly to stderr
  • Otherwise: Convert to echo '<msg>' and print that to stdout

In EB we care about stderr. Not setting LMOD_REDIRECT=no avoids capturing echo output of modules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants