Bugfix: reinstalling updated develop specs (#25579)

PackageInstaller and Package.installed disagree over what it means
for a package to be installed: PackageInstaller believes it should be
enough for a database entry to exist, whereas Package.installed
requires a database entry & a prefix directory.

This leads to the following niche issue:

* a develop spec in an environment is successfully installed
* then somehow its install prefix is removed (e.g. through a bug fixed
  in #25583)
* you modify the sources and reinstall the environment
  1. spack checks pkg.installed and realizes the develop spec is NOT
     installed, therefore it doesn't need to have 'overwrite: true'
  2. the installer gets the build task and checks the database and
      realizes the spec IS installed, hence it doesn't have to install it.
  3. the develop spec is not rebuilt.

The solution is to make PackageInstaller and pkg.installed agree over
what it means to be installed, and this PR does that by dropping the
prefix directory check from pkg.installed, so that it only checks the
database.

As a result, spack will create a build task with overwrite: true for
the develop spec, and the installer in fact handles overwrite requests
fine even if the install prefix doesn't exist (it just does a normal
install).
This commit is contained in:
Harmen Stoppels 2021-08-26 03:14:11 +02:00 committed by GitHub
parent 204b49fc1f
commit 73005166ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1252,18 +1252,14 @@ def installed(self):
Returns:
True if the package has been installed, False otherwise.
"""
has_prefix = os.path.isdir(self.prefix)
try:
# If the spec is in the DB, check the installed
# attribute of the record
rec = spack.store.db.get_record(self.spec)
db_says_installed = rec.installed
return spack.store.db.get_record(self.spec).installed
except KeyError:
# If the spec is not in the DB, the method
# above raises a Key error
db_says_installed = False
return has_prefix and db_says_installed
return False
@property
def prefix(self):