diff --git a/cabal-install-solver/src/Distribution/Solver/Modular/Message.hs b/cabal-install-solver/src/Distribution/Solver/Modular/Message.hs index e097d3e081c..652f46e8663 100644 --- a/cabal-install-solver/src/Distribution/Solver/Modular/Message.hs +++ b/cabal-install-solver/src/Distribution/Solver/Modular/Message.hs @@ -279,6 +279,7 @@ showFR :: ConflictSet -> FailReason -> String showFR _ (UnsupportedExtension ext) = " (conflict: requires " ++ showUnsupportedExtension ext ++ ")" showFR _ (UnsupportedLanguage lang) = " (conflict: requires " ++ showUnsupportedLanguage lang ++ ")" showFR _ (MissingPkgconfigPackage pn vr) = " (conflict: pkg-config package " ++ prettyShow pn ++ prettyShow vr ++ ", not found in the pkg-config database)" +showFR _ MissingPkgconfigProgram = " (pkg-config packages are needed but no pkg-config program was found)" showFR _ (NewPackageDoesNotMatchExistingConstraint d) = " (conflict: " ++ showConflictingDep d ++ ")" showFR _ (ConflictingConstraints d1 d2) = " (conflict: " ++ L.intercalate ", " (L.map showConflictingDep [d1, d2]) ++ ")" showFR _ (NewPackageIsMissingRequiredComponent comp dr) = " (does not contain " ++ showExposedComponent comp ++ ", which is required by " ++ showDependencyReason dr ++ ")" diff --git a/cabal-install-solver/src/Distribution/Solver/Modular/Tree.hs b/cabal-install-solver/src/Distribution/Solver/Modular/Tree.hs index 10d372525b1..f2037022195 100644 --- a/cabal-install-solver/src/Distribution/Solver/Modular/Tree.hs +++ b/cabal-install-solver/src/Distribution/Solver/Modular/Tree.hs @@ -102,6 +102,7 @@ data POption = POption I (Maybe PackagePath) data FailReason = UnsupportedExtension Extension | UnsupportedLanguage Language | MissingPkgconfigPackage PkgconfigName PkgconfigVersionRange + | MissingPkgconfigProgram | NewPackageDoesNotMatchExistingConstraint ConflictingDep | ConflictingConstraints ConflictingDep ConflictingDep | NewPackageIsMissingRequiredComponent ExposedComponent (DependencyReason QPN) diff --git a/cabal-install-solver/src/Distribution/Solver/Modular/Validate.hs b/cabal-install-solver/src/Distribution/Solver/Modular/Validate.hs index cbe6282b6d0..2e121d89f27 100644 --- a/cabal-install-solver/src/Distribution/Solver/Modular/Validate.hs +++ b/cabal-install-solver/src/Distribution/Solver/Modular/Validate.hs @@ -90,7 +90,7 @@ import Distribution.Types.PkgconfigVersionRange data ValidateState = VS { supportedExt :: Extension -> Bool, supportedLang :: Language -> Bool, - presentPkgs :: PkgconfigName -> PkgconfigVersionRange -> Bool, + presentPkgs :: PkgconfigName -> PkgconfigVersionRange -> Maybe Bool, index :: Index, -- Saved, scoped, dependencies. Every time 'validate' makes a package choice, @@ -383,7 +383,7 @@ extractNewDeps v b fa sa = go -- or the successfully extended assignment. extend :: (Extension -> Bool) -- ^ is a given extension supported -> (Language -> Bool) -- ^ is a given language supported - -> (PkgconfigName -> PkgconfigVersionRange -> Bool) -- ^ is a given pkg-config requirement satisfiable + -> (PkgconfigName -> PkgconfigVersionRange -> Maybe Bool) -- ^ is a given pkg-config requirement satisfiable -> [LDep QPN] -> PPreAssignment -> Either Conflict PPreAssignment @@ -398,8 +398,10 @@ extend extSupported langSupported pkgPresent newactives ppa = foldM extendSingle if langSupported lang then Right a else Left (dependencyReasonToConflictSet dr, UnsupportedLanguage lang) extendSingle a (LDep dr (Pkg pn vr)) = - if pkgPresent pn vr then Right a - else Left (dependencyReasonToConflictSet dr, MissingPkgconfigPackage pn vr) + case pkgPresent pn vr of + Just True -> Right a + Just False -> Left (dependencyReasonToConflictSet dr, MissingPkgconfigPackage pn vr) + Nothing -> Left (dependencyReasonToConflictSet dr, MissingPkgconfigProgram) extendSingle a (LDep dr (Dep dep@(PkgComponent qpn _) ci)) = let mergedDep = M.findWithDefault (MergedDepConstrained []) qpn a in case (\ x -> M.insert qpn x a) <$> merge mergedDep (PkgDep dr dep ci) of diff --git a/cabal-install-solver/src/Distribution/Solver/Types/PkgConfigDb.hs b/cabal-install-solver/src/Distribution/Solver/Types/PkgConfigDb.hs index 21845eafdec..f31276ed23b 100644 --- a/cabal-install-solver/src/Distribution/Solver/Types/PkgConfigDb.hs +++ b/cabal-install-solver/src/Distribution/Solver/Types/PkgConfigDb.hs @@ -156,17 +156,17 @@ pkgConfigDbFromList pairs = (PkgConfigDb . M.fromList . map convert) pairs -- | Check whether a given package range is satisfiable in the given -- @pkg-config@ database. -pkgConfigPkgIsPresent :: PkgConfigDb -> PkgconfigName -> PkgconfigVersionRange -> Bool +pkgConfigPkgIsPresent :: PkgConfigDb -> PkgconfigName -> PkgconfigVersionRange -> Maybe Bool pkgConfigPkgIsPresent (PkgConfigDb db) pn vr = case M.lookup pn db of - Nothing -> False -- Package not present in the DB. - Just Nothing -> True -- Package present, but version unknown. - Just (Just v) -> withinPkgconfigVersionRange v vr + Nothing -> Just False -- Package not present in the DB. + Just Nothing -> Just True -- Package present, but version unknown. + Just (Just v) -> Just $ withinPkgconfigVersionRange v vr -- If we could not read the pkg-config database successfully we fail. -- The plan found by the solver can't be executed later, because pkg-config itself -- is going to be called in the build phase to get the library location for linking -- so even if there is a library, it would need to be passed manual flags anyway. -pkgConfigPkgIsPresent NoPkgConfigDb _ _ = False +pkgConfigPkgIsPresent NoPkgConfigDb _ _ = Nothing