diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index 8b3ce15331f..ebf340e172d 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -1999,10 +1999,10 @@ def define_ad_hoc_versions_from_specs( # best possible, so they're guaranteed to be used preferentially. version = s.versions.concrete - if version is None or any( - (v == version and not isinstance(version, vn.GitVersion)) + if version is None or (not isinstance(version, vn.GitVersion) and any( + v == version for v in self.possible_versions[s.name] - ): + )): continue if require_checksum and not _is_checksummed_git_version(version):