diff --git a/lib/spack/spack/environment/environment.py b/lib/spack/spack/environment/environment.py index 7366468f7a8..1c16c708b3b 100644 --- a/lib/spack/spack/environment/environment.py +++ b/lib/spack/spack/environment/environment.py @@ -1612,9 +1612,10 @@ def install_specs(self, specs=None, **install_args): # 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.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 specs_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')