Ensure all roots of an installed environment are marked explicit in db (#24277)

This commit is contained in:
Greg Becker 2021-06-12 01:23:13 -07:00 committed by GitHub
parent d6cbf72b19
commit 95c9a031ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View File

@ -1574,6 +1574,13 @@ def install_specs(self, specs=None, args=None, **install_args):
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

View File

@ -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')