diff options
author | John W. Parent <45471568+johnwparent@users.noreply.github.com> | 2023-12-21 16:56:09 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-21 13:56:09 -0800 |
commit | 05761de8c78f2b04db3f45054cd04209992ff833 (patch) | |
tree | 834f87ca92830453c1a68d2bc897ac258973df51 /lib | |
parent | ecdf3ff297eda60180253c43a19a303a8b5a8bfd (diff) | |
download | spack-05761de8c78f2b04db3f45054cd04209992ff833.tar.gz spack-05761de8c78f2b04db3f45054cd04209992ff833.tar.bz2 spack-05761de8c78f2b04db3f45054cd04209992ff833.tar.xz spack-05761de8c78f2b04db3f45054cd04209992ff833.zip |
Improve error reporting when Clingo install is broken (#41181)
With an improper/incomplete/broken installation of Clingo, it can be
importable but not have any of the expected attributes
Improve error reporting in this case
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/solver/asp.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index ad62371c40..466348fbd1 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -18,7 +18,10 @@ from typing import Callable, Dict, List, NamedTuple, Optional, Sequence, Set, Tu import archspec.cpu +import spack.config as sc import spack.deptypes as dt +import spack.paths as sp +import spack.util.path as sup try: import clingo # type: ignore[import] @@ -28,6 +31,36 @@ try: except ImportError: clingo = None # type: ignore clingo_cffi = False +except AttributeError: + # Reaching this point indicates a broken clingo installation + # If Spack derived clingo, suggest user re-run bootstrap + # if non-spack, suggest user investigate installation + + # assume Spack is not responsibe for broken clingo + msg = ( + f"Clingo installation at {clingo.__file__} is incomplete or invalid." + "Please repair installation or re-install. " + "Alternatively, consider installing clingo via Spack." + ) + # check whether Spack is responsible + if ( + pathlib.Path( + sup.canonicalize_path(sc.get("bootstrap:root", sp.default_user_bootstrap_path)) + ) + in pathlib.Path(clingo.__file__).parents + ): + # Spack is responsible for the broken clingo + msg = ( + "Spack bootstrapped copy of Clingo is broken, " + "please re-run the bootstrapping process via command `spack bootstrap now`." + " If this issue persists, please file a bug at: github.com/spack/spack" + ) + raise RuntimeError( + "Clingo installation may be broken or incomplete, " + "please verify clingo has been installed correctly" + "\n\nClingo does not provide symbol clingo.Symbol" + f"{msg}" + ) import llnl.util.lang import llnl.util.tty as tty |