From cf18703b1392a96a5a4896a560309e501af63260 Mon Sep 17 00:00:00 2001 From: Emanuel Borsboom Date: Fri, 19 Feb 2016 13:15:49 -0800 Subject: [PATCH] Revert "init: check pkg name and .cabal file name match" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 63c7f48f6b6e7387e7ffedf5bd480114d37aff2e. @harendra-kumar The reverted commit seems to break the 1336-1337-new-package-names integration test on Mac OS X. I did a bit of debugging and it appears that, somewhere along the way, some unicode characters are changing (they look the same when rendered, but the UTF-8 bytes are different) and that is causing the comparison to fail. For example: ``` $ stack new ば日本-4本 [...] Package name as defined in the .cabal file must match the .cabal file name. Please fix the following packages and try again: - ば日本-4本/ば日本-4本.cabal ``` `show (FP.takeBaseName $ toFilePath fp,show $ gpdPackageName gpd)` in this case gives me `("\12399\12441\26085\26412-4\26412","\12400\26085\26412-4\26412")`; note the first two bytes in the fst are different than the first byte in the snd. --- src/Stack/Solver.hs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/Stack/Solver.hs b/src/Stack/Solver.hs index bbc4b8559a..6c585e7d24 100644 --- a/src/Stack/Solver.hs +++ b/src/Stack/Solver.hs @@ -515,23 +515,15 @@ cabalPackagesCheck cabalfps noPkgMsg dupErrMsg = do (warnings, gpds) <- fmap unzip (mapM readPackageUnresolved cabalfps) zipWithM_ (mapM_ . printCabalFileWarning) cabalfps warnings - -- package name cannot be empty or missing otherwise - -- it will result in cabal solver failure. - -- stack requires packages name to match the cabal file name - -- Just the latter check is enough to cover both the cases - let packages = zip cabalfps gpds - getNameMismatchPkg (fp, gpd) - | (show . gpdPackageName) gpd /= (FP.takeBaseName . toFilePath) fp - = Just fp + getEmptyNamePkg (fp, gpd) + | ((show . gpdPackageName) gpd) == "" = Just fp | otherwise = Nothing - nameMismatchPkgs = mapMaybe getNameMismatchPkg packages + emptyNamePkgs = mapMaybe getEmptyNamePkg packages - when (nameMismatchPkgs /= []) $ do - rels <- mapM makeRelativeToCurrentDir nameMismatchPkgs - error $ "Package name as defined in the .cabal file must match the \ - \.cabal file name.\n\ - \Please fix the following packages and try again:\n" + when (emptyNamePkgs /= []) $ do + rels <- mapM makeRelativeToCurrentDir emptyNamePkgs + error $ "Please assign a name to the following package(s):\n" <> (formatGroup rels) let dupGroups = filter ((> 1) . length)