summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGreg Becker <becker33@llnl.gov>2021-06-12 01:23:13 -0700
committerGitHub <noreply@github.com>2021-06-12 10:23:13 +0200
commit95c9a031ee3f425a16b37bd7ca8d3b03b49ebf76 (patch)
treecdddfae10abe91f30ea83336af4a10f99911b139 /lib
parentd6cbf72b19db58f1e2090141936274463b087f5b (diff)
downloadspack-95c9a031ee3f425a16b37bd7ca8d3b03b49ebf76.tar.gz
spack-95c9a031ee3f425a16b37bd7ca8d3b03b49ebf76.tar.bz2
spack-95c9a031ee3f425a16b37bd7ca8d3b03b49ebf76.tar.xz
spack-95c9a031ee3f425a16b37bd7ca8d3b03b49ebf76.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.py7
-rw-r--r--lib/spack/spack/test/cmd/env.py21
2 files changed, 28 insertions, 0 deletions
diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py
index bbb4298667..15921c5389 100644
--- a/lib/spack/spack/environment.py
+++ b/lib/spack/spack/environment.py
@@ -1574,6 +1574,13 @@ class Environment(object):
specs_to_install = [s for s in specs_to_install
if s not in self.roots() or s in uninstalled_roots]
+ # ensure specs already installed are marked explicit
+ all_specs = specs or [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 0c7dea4c3e..6c2ce34438 100644
--- a/lib/spack/spack/test/cmd/env.py
+++ b/lib/spack/spack/test/cmd/env.py
@@ -179,6 +179,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')