Skip to content

Commit 06d14db

Browse files
authored
Merge pull request #3640 from commercialhaskell/check-caret-operator
Better cabal file checking
2 parents 3f72ff9 + 83b8045 commit 06d14db

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Bug fixes:
1515
* For versions of Cabal before 1.24, ensure that the dependencies of
1616
non-buildable components are part of the build plan to work around an old
1717
Cabal bug.
18+
* Run the Cabal file checking in the `sdist` command more reliably by
19+
allowing the Cabal library to flatten the
20+
`GenericPackageDescription` itself.
1821

1922
## v1.6.1
2023

src/Stack/SDist.hs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,20 @@ checkPackageInExtractedTarball pkgDir = do
406406
(gdesc, PackageDescriptionPair pkgDesc _) <- readPackageDescriptionDir config pkgDir False
407407
logInfo $
408408
"Checking package '" <> packageNameText name <> "' for common mistakes"
409-
let pkgChecks = Check.checkPackage gdesc (Just pkgDesc)
409+
let pkgChecks =
410+
-- MSS 2017-12-12: Try out a few different variants of
411+
-- pkgDesc to try and provoke an error or warning. I don't
412+
-- know why, but when using `Just pkgDesc`, it appears that
413+
-- Cabal does not detect that `^>=` is used with
414+
-- `cabal-version: 1.24` or earlier. It seems like pkgDesc
415+
-- (the one we create) does not populate the `buildDepends`
416+
-- field, whereas flattenPackageDescription from Cabal
417+
-- does. In any event, using `Nothing` seems more logical
418+
-- for this check anyway, and the fallback to `Just pkgDesc`
419+
-- is just a crazy sanity check.
420+
case Check.checkPackage gdesc Nothing of
421+
[] -> Check.checkPackage gdesc (Just pkgDesc)
422+
x -> x
410423
fileChecks <- liftIO $ Check.checkPackageFiles pkgDesc (toFilePath pkgDir)
411424
let checks = pkgChecks ++ fileChecks
412425
(errors, warnings) =

0 commit comments

Comments
 (0)