nonexistent module concise error message (#35502)

This commit is contained in:
simon-Leary42 2023-02-21 07:50:56 -05:00 committed by GitHub
parent 5b8917188a
commit 33bf1fd033
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -399,13 +399,19 @@ def get_module(module_type, spec, get_full_path, module_set_name="default", requ
else:
writer = spack.modules.module_types[module_type](spec, module_set_name)
if not os.path.isfile(writer.layout.filename):
fmt_str = "{name}{@version}{/hash:7}"
if not writer.conf.excluded:
err_msg = "No module available for package {0} at {1}".format(
spec, writer.layout.filename
raise ModuleNotFoundError(
"The module for package {} should be at {}, but it does not exist".format(
spec.format(fmt_str), writer.layout.filename
)
)
raise ModuleNotFoundError(err_msg)
elif required:
tty.debug("The module configuration has excluded {0}: " "omitting it".format(spec))
tty.debug(
"The module configuration has excluded {}: omitting it".format(
spec.format(fmt_str)
)
)
else:
return None