From 5b9f60f9bb159113bfd8a0c8f3f4a8a0c2f55d7e Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Fri, 1 Oct 2021 13:00:14 +0200 Subject: bootstrapping: improve error messages (#26399) --- lib/spack/spack/bootstrap.py | 21 ++++++++++++++++++--- lib/spack/spack/spec.py | 13 ++++++++----- 2 files changed, 26 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/bootstrap.py b/lib/spack/spack/bootstrap.py index fbfeefe92f..ca92b6fad0 100644 --- a/lib/spack/spack/bootstrap.py +++ b/lib/spack/spack/bootstrap.py @@ -216,6 +216,10 @@ class _BuildcacheBootstrapper(object): # specs that wwe know by dag hash. spack.binary_distribution.binary_index.regenerate_spec_cache() index = spack.binary_distribution.update_cache_and_get_specs() + + if not index: + raise RuntimeError("Could not populate the binary index") + for item in data['verified']: candidate_spec = item['spec'] python_spec = item['python'] @@ -273,6 +277,8 @@ class _SourceBootstrapper(object): if _try_import_from_store(module, abstract_spec_str): return True + tty.info("Bootstrapping {0} from sources".format(module)) + # Try to build and install from sources with spack_python_interpreter(): # Add hint to use frontend operating system on Cray @@ -285,16 +291,15 @@ class _SourceBootstrapper(object): if module == 'clingo': # TODO: remove when the old concretizer is deprecated - concrete_spec._old_concretize() + concrete_spec._old_concretize(deprecation_warning=False) else: concrete_spec.concretize() msg = "[BOOTSTRAP MODULE {0}] Try installing '{1}' from sources" tty.debug(msg.format(module, abstract_spec_str)) - tty.info("Bootstrapping {0} from sources".format(module)) # Install the spec that should make the module importable - concrete_spec.package.do_install() + concrete_spec.package.do_install(fail_fast=True) return _try_import_from_store(module, abstract_spec_str=abstract_spec_str) @@ -377,6 +382,9 @@ def ensure_module_importable_or_raise(module, abstract_spec=None): abstract_spec = abstract_spec or module source_configs = spack.config.get('bootstrap:sources', []) + + errors = {} + for current_config in source_configs: if not _source_is_trusted(current_config): msg = ('[BOOTSTRAP MODULE {0}] Skipping source "{1}" since it is ' @@ -391,11 +399,18 @@ def ensure_module_importable_or_raise(module, abstract_spec=None): except Exception as e: msg = '[BOOTSTRAP MODULE {0}] Unexpected error "{1}"' tty.debug(msg.format(module, str(e))) + errors[current_config['name']] = e # We couldn't import in any way, so raise an import error msg = 'cannot bootstrap the "{0}" Python module'.format(module) if abstract_spec: msg += ' from spec "{0}"'.format(abstract_spec) + msg += ' due to the following failures:\n' + for method in errors: + err = errors[method] + msg += " '{0}' raised {1}: {2}\n".format( + method, err.__class__.__name__, str(err)) + msg += ' Please run `spack -d spec zlib` for more verbose error messages' raise ImportError(msg) diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index fc8edea6aa..9fa97f3340 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -2357,13 +2357,15 @@ class Spec(object): return changed - def _old_concretize(self, tests=False): + def _old_concretize(self, tests=False, deprecation_warning=True): """A spec is concrete if it describes one build of a package uniquely. This will ensure that this spec is concrete. Args: tests (list or bool): list of packages that will need test dependencies, or True/False for test all/none + deprecation_warning (bool): enable or disable the deprecation + warning for the old concretizer If this spec could describe more than one version, variant, or build of a package, this will add constraints to make it concrete. @@ -2377,10 +2379,11 @@ class Spec(object): # Add a warning message to inform users that the original concretizer # will be removed in v0.18.0 - msg = ('the original concretizer is currently being used.\n\tUpgrade to ' - '"clingo" at your earliest convenience. The original concretizer ' - 'will be removed from Spack starting at v0.18.0') - warnings.warn(msg) + if deprecation_warning: + msg = ('the original concretizer is currently being used.\n\tUpgrade to ' + '"clingo" at your earliest convenience. The original concretizer ' + 'will be removed from Spack starting at v0.18.0') + warnings.warn(msg) if not self.name: raise spack.error.SpecError( -- cgit v1.2.3-70-g09d2