diff --git a/cabal-install/Distribution/Solver/Modular/IndexConversion.hs b/cabal-install/Distribution/Solver/Modular/IndexConversion.hs index 413c62ee51d..13b1eca5d99 100644 --- a/cabal-install/Distribution/Solver/Modular/IndexConversion.hs +++ b/cabal-install/Distribution/Solver/Modular/IndexConversion.hs @@ -12,6 +12,7 @@ import Distribution.Compiler import Distribution.InstalledPackageInfo as IPI import Distribution.Package -- from Cabal import Distribution.Simple.BuildToolDepends -- from Cabal +import Distribution.Simple.Utils (cabalVersion) -- from Cabal import Distribution.Types.ExeDependency -- from Cabal import Distribution.Types.PkgconfigDependency -- from Cabal import Distribution.Types.ComponentName -- from Cabal @@ -191,8 +192,37 @@ convGPD os arch cinfo strfl solveExes pn addStanza :: Stanza -> DependencyReason pn -> DependencyReason pn addStanza s (DependencyReason pn' fs ss) = DependencyReason pn' fs (s : ss) + + -- | We infer the maximally supported spec-version from @lib:Cabal@'s version + -- + -- As we cannot predict the future, we can only properly support + -- spec-versions predating (and including) the @lib:Cabal@ version + -- used by @cabal-install@. + -- + -- This relies on 'cabalVersion' having always at least 3 components to avoid + -- comparisons like @2.0.0 > 2.0@ which would result in confusing results. + -- + -- NOTE: Before we can switch to a /normalised/ spec-version + -- comparison (e.g. by truncating to 3 components, and removing + -- trailing zeroes) we'd have to make sure all other places where + -- the spec-version is compared against a bound do it + -- consistently. + maxSpecVer = cabalVersion + + -- | Required/declared spec-version of the package + -- + -- We don't truncate patch-levels, as specifying a patch-level + -- spec-version is discouraged and not supported anymore starting + -- with spec-version 2.2. + reqSpecVer = specVersion pkg + + -- | A too-new specVersion is turned into a global 'FailReason' + -- which prevents the solver from selecting this release (and if + -- forced to, emit a meaningful solver error message). + fr | reqSpecVer > maxSpecVer = Just (UnsupportedSpecVer reqSpecVer) + | otherwise = Nothing in - PInfo flagged_deps (L.map fst exes) fds Nothing + PInfo flagged_deps (L.map fst exes) fds fr -- | Create a flagged dependency tree from a list @fds@ of flagged -- dependencies, using @f@ to form the tree node (@f@ will be diff --git a/cabal-install/Distribution/Solver/Modular/Message.hs b/cabal-install/Distribution/Solver/Modular/Message.hs index 19bc0789371..99eecc843ee 100644 --- a/cabal-install/Distribution/Solver/Modular/Message.hs +++ b/cabal-install/Distribution/Solver/Modular/Message.hs @@ -146,6 +146,7 @@ showFR c Backjump = " (backjumping, conflict set: " ++ s showFR _ MultipleInstances = " (multiple instances)" showFR c (DependenciesNotLinked msg) = " (dependencies not linked: " ++ msg ++ "; conflict set: " ++ showConflictSet c ++ ")" showFR c CyclicDependencies = " (cyclic dependencies; conflict set: " ++ showConflictSet c ++ ")" +showFR _ (UnsupportedSpecVer ver) = " (unsupported spec-version " ++ display ver ++ ")" -- The following are internal failures. They should not occur. In the -- interest of not crashing unnecessarily, we still just print an error -- message though. diff --git a/cabal-install/Distribution/Solver/Modular/Tree.hs b/cabal-install/Distribution/Solver/Modular/Tree.hs index 6ae1b22a967..91c2f9becc4 100644 --- a/cabal-install/Distribution/Solver/Modular/Tree.hs +++ b/cabal-install/Distribution/Solver/Modular/Tree.hs @@ -118,6 +118,7 @@ data FailReason = UnsupportedExtension Extension | MultipleInstances | DependenciesNotLinked String | CyclicDependencies + | UnsupportedSpecVer Ver deriving (Eq, Show) -- | Information about a dependency involved in a conflict, for error messages. diff --git a/cabal-testsuite/PackageTests/CustomWithoutCabal/custom-setup-without-cabal.cabal b/cabal-testsuite/PackageTests/CustomWithoutCabal/custom-setup-without-cabal.cabal index 7abdee77c71..64d2e55de4f 100644 --- a/cabal-testsuite/PackageTests/CustomWithoutCabal/custom-setup-without-cabal.cabal +++ b/cabal-testsuite/PackageTests/CustomWithoutCabal/custom-setup-without-cabal.cabal @@ -1,7 +1,7 @@ +cabal-version: 2.0 name: custom-setup-without-cabal version: 1.0 build-type: Custom -cabal-version: >= 99999 custom-setup setup-depends: base diff --git a/cabal-testsuite/PackageTests/Regression/T3436/custom-setup/custom-setup.cabal b/cabal-testsuite/PackageTests/Regression/T3436/custom-setup/custom-setup.cabal index 923de11e862..f06d6644610 100644 --- a/cabal-testsuite/PackageTests/Regression/T3436/custom-setup/custom-setup.cabal +++ b/cabal-testsuite/PackageTests/Regression/T3436/custom-setup/custom-setup.cabal @@ -1,7 +1,7 @@ +cabal-version: 2.0 name: custom-setup version: 1.0 build-type: Custom -cabal-version: >= 99999 custom-setup setup-depends: base, Cabal >= 99999