concretizer:unify:true as a default (#31787)
`spack env create` enables a view by default (in a weird hidden directory, but well...). This is asking for trouble with the other default of `concretizer:unify:false`, since having different flavors of the same spec in an environment, leads to collision errors when generating the view. A change of defaults would improve user experience: However, `unify:true` makes most sense, since any time the issue is brought up in Slack, the user changes the concretization config, since it wasn't the intention to have different flavors of the same spec, and install times are decreased. Further we improve the docs and drop the duplicate root spec limitation
This commit is contained in:
@@ -1322,30 +1322,25 @@ def _concretize_together(self, tests=False):
|
||||
if user_specs_did_not_change:
|
||||
return []
|
||||
|
||||
# Check that user specs don't have duplicate packages
|
||||
counter = collections.defaultdict(int)
|
||||
for user_spec in self.user_specs:
|
||||
counter[user_spec.name] += 1
|
||||
|
||||
duplicates = []
|
||||
for name, count in counter.items():
|
||||
if count > 1:
|
||||
duplicates.append(name)
|
||||
|
||||
if duplicates:
|
||||
msg = (
|
||||
"environment that are configured to concretize specs"
|
||||
" together cannot contain more than one spec for each"
|
||||
" package [{0}]".format(", ".join(duplicates))
|
||||
)
|
||||
raise SpackEnvironmentError(msg)
|
||||
|
||||
# Proceed with concretization
|
||||
self.concretized_user_specs = []
|
||||
self.concretized_order = []
|
||||
self.specs_by_hash = {}
|
||||
|
||||
concrete_specs = spack.concretize.concretize_specs_together(*self.user_specs, tests=tests)
|
||||
try:
|
||||
concrete_specs = spack.concretize.concretize_specs_together(
|
||||
*self.user_specs, tests=tests
|
||||
)
|
||||
except spack.error.UnsatisfiableSpecError as e:
|
||||
# "Enhance" the error message for multiple root specs, suggest a less strict
|
||||
# form of concretization.
|
||||
if len(self.user_specs) > 1:
|
||||
e.message += (
|
||||
". Consider setting `concretizer:unify` to `when_possible` "
|
||||
"or `false` to relax the concretizer strictness."
|
||||
)
|
||||
raise
|
||||
|
||||
concretized_specs = [x for x in zip(self.user_specs, concrete_specs)]
|
||||
for abstract, concrete in concretized_specs:
|
||||
self._add_concrete_spec(abstract, concrete)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
import spack.cmd.env
|
||||
import spack.environment as ev
|
||||
import spack.environment.shell
|
||||
import spack.error
|
||||
import spack.modules
|
||||
import spack.paths
|
||||
import spack.repo
|
||||
@@ -2403,7 +2404,9 @@ def test_duplicate_packages_raise_when_concretizing_together():
|
||||
e.add("mpileaks~opt")
|
||||
e.add("mpich")
|
||||
|
||||
with pytest.raises(ev.SpackEnvironmentError, match=r"cannot contain more"):
|
||||
with pytest.raises(
|
||||
spack.error.UnsatisfiableSpecError, match=r"relax the concretizer strictness"
|
||||
):
|
||||
e.concretize()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user