diff options
-rw-r--r-- | lib/spack/spack/environment/environment.py | 21 | ||||
-rw-r--r-- | lib/spack/spack/test/env.py | 14 |
2 files changed, 24 insertions, 11 deletions
diff --git a/lib/spack/spack/environment/environment.py b/lib/spack/spack/environment/environment.py index 8837e2cecd..b00405b5d1 100644 --- a/lib/spack/spack/environment/environment.py +++ b/lib/spack/spack/environment/environment.py @@ -1956,17 +1956,16 @@ class Environment: specs = specs if specs is not None else roots # Extend the set of specs to overwrite with modified dev specs and their parents - overwrite: Set[str] = set() - overwrite.update(install_args.get("overwrite", []), self._dev_specs_that_need_overwrite()) - install_args["overwrite"] = overwrite - - explicit: Set[str] = set() - explicit.update( - install_args.get("explicit", []), - (s.dag_hash() for s in specs), - (s.dag_hash() for s in roots), - ) - install_args["explicit"] = explicit + install_args["overwrite"] = { + *install_args.get("overwrite", ()), + *self._dev_specs_that_need_overwrite(), + } + + # Only environment roots are marked explicit + install_args["explicit"] = { + *install_args.get("explicit", ()), + *(s.dag_hash() for s in roots), + } PackageInstaller([spec.package for spec in specs], **install_args).install() diff --git a/lib/spack/spack/test/env.py b/lib/spack/spack/test/env.py index 682540361f..3f2183f5e2 100644 --- a/lib/spack/spack/test/env.py +++ b/lib/spack/spack/test/env.py @@ -892,3 +892,17 @@ spack: with pytest.raises(Exception): with ev.Environment(tmp_path) as e: e.concretize() + + +def test_only_roots_are_explicitly_installed(tmp_path, mock_packages, config, temporary_store): + """When installing specific non-root specs from an environment, we continue to mark them + as implicitly installed. What makes installs explicit is that they are root of the env.""" + env = ev.create_in_dir(tmp_path) + env.add("mpileaks") + env.concretize() + mpileaks = env.concrete_roots()[0] + callpath = mpileaks["callpath"] + env.install_specs([callpath], fake=True) + assert callpath in temporary_store.db.query(explicit=False) + env.install_specs([mpileaks], fake=True) + assert temporary_store.db.query(explicit=True) == [mpileaks] |