Skip to content

Solver: shorten the skipping message if needed #11062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -282,16 +282,16 @@ showOption qpn@(Q _pp pn) (POption i linkedTo) =
-- >>> showOptions foobarQPN [k1, k2]
-- "foo-bar; foo-bar~>bazqux.foo-bar-1, foo-bar~>bazqux.foo-bar-2"
-- >>> showOptions foobarQPN [v0, i1, k2]
-- "foo-bar; 0, 1/installed-inplace, foo-bar~>bazqux.foo-bar-2"
-- "foo-bar; 0, 1/installed-inplace, foo-bar~>bazqux.foo-bar-2 and earlier versions"
showOptions :: QPN -> [POption] -> String
showOptions _ [] = "unexpected empty list of versions"
showOptions q [x] = showOption q x
showOptions q xs = showQPN q ++ "; " ++ (L.intercalate ", "
[if isJust linkedTo
then showOption q x
else showI i -- Don't show the package, just the version
| x@(POption i linkedTo) <- xs
])
| x@(POption i linkedTo) <- take 3 xs
] ++ if length xs >= 3 then " and earlier versions" else "")
Copy link
Member Author

@erikd erikd Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I use a number less that 3 here, a number of the UnitTest tests (4 to 6 from memory) will fail.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, when length of xs is exactly 3, cabal will print the entirety of the list but still says "and earlier versions"?..

3 looks like too many still. I'd suggest print 1 and fix the unit tests.


showGR :: QGoalReason -> String
showGR UserGoal = " (user goal)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,19 @@ tests =
skipping = "skipping: A; 2.0.0/installed-2.0.0, 1.0.0/installed-1.0.0"
in mkTest db "show skipping versions list, installed" ["B"] $
solverFailure (\msg -> rejecting `isInfixOf` msg && skipping `isInfixOf` msg)
, runTest $
let db =
[ Right $ exAv "A" 1 []
, Right $ exAv "A" 2 []
, Right $ exAv "A" 3 []
, Right $ exAv "A" 4 []
, Right $ exAv "A" 5 []
, Right $ exAv "B" 1 [ExFix "A" 6]
]
rejecting = "rejecting: A-5.0.0 (conflict: B => A==6.0.0)"
skipping = "skipping: A; 4.0.0, 3.0.0, 2.0.0 and earlier versions (has"
in mkTest db "show summarized skipping versions list" ["B"] $
solverFailure (\msg -> rejecting `isInfixOf` msg && skipping `isInfixOf` msg)
]
]
]
Expand Down
8 changes: 8 additions & 0 deletions changelog.d/pr-11062
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
synopsis: Solver: shorten the skipping message if needed
packages: cabal-install-solver
prs: #11062

When the solver fails to find a solution, it can print out a long list
of package versions which failed to meet the requirements. This PR
shortens the message to at most 3 versions which failed to meet the
requriements.
Loading