nonexistent module concise error message (#35502)
This commit is contained in:
parent
c8f7c78e73
commit
9c1c5c2936
@ -34,7 +34,7 @@
|
|||||||
import inspect
|
import inspect
|
||||||
import os.path
|
import os.path
|
||||||
import re
|
import re
|
||||||
from typing import Optional # novm
|
from typing import Optional # novm # noqa: F401
|
||||||
|
|
||||||
import llnl.util.filesystem
|
import llnl.util.filesystem
|
||||||
import llnl.util.tty as tty
|
import llnl.util.tty as tty
|
||||||
@ -402,13 +402,19 @@ def get_module(module_type, spec, get_full_path, module_set_name="default", requ
|
|||||||
else:
|
else:
|
||||||
writer = spack.modules.module_types[module_type](spec, module_set_name)
|
writer = spack.modules.module_types[module_type](spec, module_set_name)
|
||||||
if not os.path.isfile(writer.layout.filename):
|
if not os.path.isfile(writer.layout.filename):
|
||||||
|
fmt_str = "{name}{@version}{/hash:7}"
|
||||||
if not writer.conf.excluded:
|
if not writer.conf.excluded:
|
||||||
err_msg = "No module available for package {0} at {1}".format(
|
raise ModuleNotFoundError(
|
||||||
spec, writer.layout.filename
|
"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:
|
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:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user