Skip to content

Discover EasyBuild toolchains eagerly to work around ReFrame sys.path corruption - #370

Merged
smoors merged 3 commits into
EESSI:mainfrom
casparvl:fix_GCC_keyerror
Dec 3, 2026
Merged

smoors merged 3 commits into
EESSI:mainfrom
casparvl:fix_GCC_keyerror

Conversation

@casparvl

@casparvl casparvl commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

The toolchains are known to EasyBuild, and get_toolchain_hierarchy works fine in a standalone script. The underlying error is KeyError: 'GCC', because EasyBuild's toolchain registry only contains GCCcore.

Root cause

  1. EasyBuild discovers toolchain classes lazily, on the first call to search_toolchain(). It does this by globbing easybuild/toolchains/*.py over every entry in sys.path.
  2. eessi/testsuite/utils.py calls EasyBuild's set_up_configuration() at import time. That inserts a temporary fake_vsc directory at sys.path[0].
  3. ReFrame loads each check file inside a temp_sys_path context manager. It appends the check's directory to sys.path, records the index, and on exit runs sys.path.pop(<recorded index>).
  4. Our import happens while the check file is being loaded. The insert at sys.path[0] shifts every index by one. ReFrame's cleanup then pops the wrong entry, which is site-packages, and leaves its own directory behind.
  5. When EasyBuild later does its lazy discovery, site-packages is no longer on sys.path, so only GCCcore is found.

Fix

Call search_toolchain('') directly after set_up_configuration(). This forces toolchain discovery at import time, while sys.path is still intact. The result is cached by EasyBuild, so later calls are unaffected.

The bug is arguably in ReFrame, which - by popping by index - assumes tests never alter the sys.path. A better approach would probably be to remove something by value, or even restore the sys-path from a snapshot - so that any changes done by a test are also 'cleared'. In any case, even if such a change is made in ReFrame, the fix here is harmless.

Testing

reframe --list -c eessi/testsuite/tests/libs/blas/ -p EESSI-2025.06 no longer printed any KeyError:'GCC'

Solves #369

@casparvl casparvl changed the title Fix GCC key error by making sure toolchains are discovered before ReFrame alters the sys.path Fix GCC key error Nov 18, 2026
@casparvl casparvl changed the title Fix GCC key error Discover EasyBuild toolchains eagerly to work around ReFrame sys.path corruption Nov 18, 2026
Comment thread eessi/testsuite/utils.py Resolved
Comment thread eessi/testsuite/utils.py Resolved
Comment thread eessi/testsuite/utils.py Resolved
@smoors
smoors merged commit b4b0642 into EESSI:main Dec 3, 2026
16 checks passed
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.

2 participants