pkg: minimize number of packages flagged avoid-version #11494
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
dune pkg lock
currently fails to find a solution when a dependency flagged asavoid-version
is absolutely necessary (see e.g. issue #11136). PR #10668 disallowed all package versions with the avoid flag, since they can result in unwanted solutions (typically: selecting an unstable version of the compiler, when a stable version would have worked).We discussed during the dune dev meeting that a command-line flag could be added to toggle that behavior, but I didn't really like it... To provide users with a nice error message with a suggestion to re-run
dune pkg lock --allow-avoid-version
, we would need to know when this flag would help (so why not do it by default?). Furthermore as soon as the avoid-versions are allowed in the search space, the SAT solver starts using them for unnecessary purposes (like picking an unstable compiler): Even though the avoid-version are deprioritized, the SAT solver is greedy and will happily use them to satisfy an earlier choice instead of backtracking. In practice we would like it to only pick the absolutely unavoidable packages, but stick to recommended dependencies otherwise.This yields a simple plan to minimize the number of avoid-version packages included in the solution:
at most N
SAT constraint withlower <= N < upper
. The SAT solver already supportedat_most_one
clauses, so theat_most N
generalization was nearly available.Finally the UI displays a warning for all the unavoidable avoid-version, so that the user is informed and can dig into the issue if they desire.