summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 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')