Skip to content

Fix relative modulepath resolution during modulefile evaluation - #700

Open
xdelaruelle wants to merge 2 commits into
envmodules:mainfrom
xdelaruelle:openhpc-integ
Open

xdelaruelle wants to merge 2 commits into
envmodules:mainfrom
xdelaruelle:openhpc-integ

Conversation

@xdelaruelle

Copy link
Copy Markdown
Collaborator

Two changes coming out of the integration of Modules in OpenHPC.

A relative path entry in MODULEPATH was made absolute against the directory of the modulefile being evaluated when a module load, prereq or depends-on command ran inside a modulefile. The required module was searched in a wrong directory and reported as not found. Relative modulepath entries now always refer to the current working directory of the module command, whatever the evaluation context. is-used is adjusted to still recognize a raw relative entry passed as argument, as module unuse already does, since its arguments resolve relatively to the modulefile directory. Tests cover both the relative/dir and ./relative/dir forms.

The second commit documents that, when conflict_unload is enabled, a variable set by the loading modulefile prior to its conflict, family or module unload command is lost if the unloaded conflicting modulefile also sets it. This is another reason to declare dependencies before environment changes. The behavior is covered in the testsuite.

When conflict_unload is enabled, the conflicting loaded module is
unloaded at the time the conflict, family or module unload command is
evaluated. A variable set by the loading modulefile before this command
is unset by this unload if the conflicting modulefile also sets it.

Document this behavior as another reason to declare dependencies prior
environment changes and cover it in the testsuite.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
A relative path entry in MODULEPATH is made absolute by the procedure
which uses the directory of the modulefile being evaluated as base when
an evaluation is ongoing. A module loaded from within a modulefile, with
a "module load", "prereq" or "depends-on" command, is thus searched in a
wrong directory and reported as not found.

Relative modulepath entries refer to the current working directory of
the module command, whatever the evaluation context. Add an option to
the path resolution procedure to force this base directory and use it
when resolving modulepath entries.

The "is-used" modulefile command resolves its arguments relatively to
the modulefile directory, so a raw relative MODULEPATH entry passed as
argument does not match the entry once resolved from the current working
directory. Check argument against the raw MODULEPATH content first, as
"module unuse" does, to keep such argument recognized as used.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant