diff options
author | Greg Becker <becker33@llnl.gov> | 2021-06-12 01:23:13 -0700 |
---|---|---|
committer | Greg Becker <becker33@llnl.gov> | 2021-09-21 16:58:41 -0700 |
commit | 0e85d7011eb21e17252c114141531be380d38ed3 (patch) | |
tree | 99202f62e86b2de2d73ece68db25c81a92e1961a /lib | |
parent | 77e633efa1a33bd87c580ed506656fe57c0b8b73 (diff) | |
download | spack-0e85d7011eb21e17252c114141531be380d38ed3.tar.gz spack-0e85d7011eb21e17252c114141531be380d38ed3.tar.bz2 spack-0e85d7011eb21e17252c114141531be380d38ed3.tar.xz spack-0e85d7011eb21e17252c114141531be380d38ed3.zip |
Ensure all roots of an installed environment are marked explicit in db (#24277)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/environment.py | 7 | ||||
-rw-r--r-- | lib/spack/spack/test/cmd/env.py | 21 |
2 files changed, 28 insertions, 0 deletions
diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py index 7f7625f2e6..6d0033d646 100644 --- a/lib/spack/spack/environment.py +++ b/lib/spack/spack/environment.py @@ -1420,6 +1420,13 @@ class Environment(object): # DB read transaction to reduce time spent in this case. specs_to_install = self.uninstalled_specs() + # ensure specs already installed are marked explicit + all_specs = [cs for _, cs in self.concretized_specs()] + specs_installed = [s for s in all_specs if s.package.installed] + with spack.store.db.write_transaction(): # do all in one transaction + for spec in specs_installed: + spack.store.db.update_explicit(spec, True) + if not specs_to_install: tty.msg('All of the packages are already installed') return diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py index f43ea4ff32..ac96b5f606 100644 --- a/lib/spack/spack/test/cmd/env.py +++ b/lib/spack/spack/test/cmd/env.py @@ -176,6 +176,27 @@ def test_env_install_single_spec(install_mockery, mock_fetch): assert e.specs_by_hash[e.concretized_order[0]].name == 'cmake-client' +def test_env_roots_marked_explicit(install_mockery, mock_fetch): + install = SpackCommand('install') + install('dependent-install') + + # Check one explicit, one implicit install + dependent = spack.store.db.query(explicit=True) + dependency = spack.store.db.query(explicit=False) + assert len(dependent) == 1 + assert len(dependency) == 1 + + env('create', 'test') + with ev.read('test') as e: + # make implicit install a root of the env + e.add(dependency[0].name) + e.concretize() + e.install_all() + + explicit = spack.store.db.query(explicit=True) + assert len(explicit) == 2 + + def test_env_modifications_error_on_activate( install_mockery, mock_fetch, monkeypatch, capfd): env('create', 'test') |