From 7ec9dd8f4856a1868c906d49c2e781dea317b8e7 Mon Sep 17 00:00:00 2001
From: "Paolo G. Giarrusso"
Date: Thu, 21 Jul 2016 02:20:04 +0200
Subject: [PATCH] Normalize to NFC before comparison (fix #1810)
The filename gets normalized to NFD on OS X causing spurious failures.
Let's normalize both sides to NFC in case the Cabal file is in some
other normalization for any reason.
This is a slight hack.
---
src/Stack/Solver.hs | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/Stack/Solver.hs b/src/Stack/Solver.hs
index e965f098d2..7665722907 100644
--- a/src/Stack/Solver.hs
+++ b/src/Stack/Solver.hs
@@ -76,6 +76,8 @@ import qualified System.Directory as D
import qualified System.FilePath as FP
import System.Process.Read
+import qualified Data.Text.Normalize as T ( normalize )
+import Data.Unicode.Types ( NormalizationMode(NFC) )
data ConstraintType = Constraint | Preference deriving (Eq)
type ConstraintSpec = Map PackageName (Version, Map FlagName Bool)
@@ -560,8 +562,10 @@ cabalPackagesCheck cabalfps noPkgMsg dupErrMsg = do
-- Just the latter check is enough to cover both the cases
let packages = zip cabalfps gpds
+ -- XXX taken from https://github.com/ppelleti/normalization-insensitive, see #1810
+ unicodeNormalize = T.unpack . T.normalize NFC . T.pack
getNameMismatchPkg (fp, gpd)
- | (show . gpdPackageName) gpd /= (FP.takeBaseName . toFilePath) fp
+ | (unicodeNormalize . show . gpdPackageName) gpd /= (unicodeNormalize . FP.takeBaseName . toFilePath) fp
= Just fp
| otherwise = Nothing
nameMismatchPkgs = mapMaybe getNameMismatchPkg packages