Skip to content

Commit f437d94

Browse files
authored
Merge pull request #6498 from grayjay/issue-5892-2
Show full ABI hash for installed packages in solver log (fixes #5892).
2 parents 4026d57 + 4660e90 commit f437d94

File tree

4 files changed

+23
-14
lines changed

4 files changed

+23
-14
lines changed

cabal-install/Distribution/Solver/Modular/Package.hs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ module Distribution.Solver.Modular.Package
1818
, unPN
1919
) where
2020

21-
import Data.List as L
21+
import Prelude ()
22+
import Distribution.Solver.Compat.Prelude
2223

2324
import Distribution.Package -- from Cabal
2425
import Distribution.Deprecated.Text (display)
@@ -57,14 +58,12 @@ data I = I Ver Loc
5758
-- | String representation of an instance.
5859
showI :: I -> String
5960
showI (I v InRepo) = showVer v
60-
showI (I v (Inst uid)) = showVer v ++ "/installed" ++ shortId uid
61+
showI (I v (Inst uid)) = showVer v ++ "/installed" ++ extractPackageAbiHash uid
6162
where
62-
-- A hack to extract the beginning of the package ABI hash
63-
shortId = snip (splitAt 4) (++ "...")
64-
. snip ((\ (x, y) -> (reverse x, y)) . break (=='-') . reverse) ('-':)
65-
. display
66-
snip p f xs = case p xs of
67-
(ys, zs) -> (if L.null zs then id else f) ys
63+
extractPackageAbiHash xs =
64+
case first reverse $ break (=='-') $ reverse (display xs) of
65+
(ys, []) -> ys
66+
(ys, _) -> '-' : ys
6867

6968
-- | Package instance. A package name and an instance.
7069
data PI qpn = PI qpn I

cabal-install/tests/UnitTests/Distribution/Solver/Modular/Solver.hs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,18 @@ tests = [
708708
"minimize conflict set with --minimize-conflict-set"
709709
, testNoMinimizeConflictSet
710710
"show original conflict set with --no-minimize-conflict-set"
711+
, runTest $
712+
let db = [ Right $ exAv "my-package" 1 [ExFix "other-package" 3]
713+
, Left $ exInst "other-package" 2 "other-package-2.0.0" []]
714+
msg = "rejecting: other-package-2.0.0/installed-2.0.0"
715+
in mkTest db "show full installed package version (issue #5892)" ["my-package"] $
716+
solverFailure (isInfixOf msg)
717+
, runTest $
718+
let db = [ Right $ exAv "my-package" 1 [ExFix "other-package" 3]
719+
, Left $ exInst "other-package" 2 "other-package-AbCdEfGhIj0123456789" [] ]
720+
msg = "rejecting: other-package-2.0.0/installed-AbCdEfGhIj0123456789"
721+
in mkTest db "show full installed package ABI hash (issue #5892)" ["my-package"] $
722+
solverFailure (isInfixOf msg)
711723
]
712724
]
713725
where

cabal-testsuite/PackageTests/Backpack/Includes2/setup-external.cabal.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Warning: solver failed to find a solution:
101101
Could not resolve dependencies:
102102
[__0] trying: exe-0.1.0.0 (user goal)
103103
[__1] next goal: src (dependency of exe)
104-
[__1] rejecting: src-<VERSION>/installed-<HASH>... (conflict: src => mylib==0.1.0.0/installed-0.1..., src => mylib==0.1.0.0/installed-0.1...)
104+
[__1] rejecting: src-<VERSION>/installed-<HASH> (conflict: src => mylib==<VERSION>/installed-<HASH>, src => mylib==<VERSION>/installed-<HASH>)
105105
[__1] fail (backjumping, conflict set: exe, src)
106106
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: exe (2), src (2)
107107
Trying configure anyway.

cabal-testsuite/Test/Cabal/OutputNormalizer.hs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,11 @@ normalizeOutput nenv =
3333
. resub (posixRegexEscape (normalizerRoot nenv)) "<ROOT>/"
3434
. resub (posixRegexEscape (normalizerTmpDir nenv)) "<TMPDIR>/"
3535
. appEndo (F.fold (map (Endo . packageIdRegex) (normalizerKnownPackages nenv)))
36-
-- Look for foo-0.1/installed-0d6...
36+
-- Look for 0.1/installed-0d6uzW7Ubh1Fb4TB5oeQ3G
3737
-- These installed packages will vary depending on GHC version
38-
-- Makes assumption that installed packages don't have numbers
39-
-- in package name segment.
4038
-- Apply this before packageIdRegex, otherwise this regex doesn't match.
41-
. resub "([a-zA-Z]+(-[a-zA-Z])*)-[0-9]+(\\.[0-9]+)*/installed-[A-Za-z0-9.]+"
42-
"\\1-<VERSION>/installed-<HASH>..."
39+
. resub "[0-9]+(\\.[0-9]+)*/installed-[A-Za-z0-9.+]+"
40+
"<VERSION>/installed-<HASH>"
4341
-- Normalize architecture
4442
. resub (posixRegexEscape (display (normalizerPlatform nenv))) "<ARCH>"
4543
-- Some GHC versions are chattier than others

0 commit comments

Comments
 (0)