Commit 9e90e150 authored by bjorn@bringert.net's avatar bjorn@bringert.net
Browse files

Fixed error message when some depedencies couldn't be resolved. Before it used...

Fixed error message when some depedencies couldn't be resolved. Before it used show on Dependency, not showDependency.
Using fail here produces things like:
cabal: user error (Unresolved dependencies: containers -any, array -any, bytestring >=0.9)
It would be nice to get rid of the "user error" here. 
parent df8ed61d
......@@ -33,6 +33,7 @@ import System.Directory (doesFileExist, createDirectoryIfMissing)
import Hackage.Types (ConfigFlags (..), UnresolvedDependency (..), Repo(..), PkgInfo, pkgInfoId)
import Hackage.Config (repoCacheDir, packageFile, packageDir, pkgURL, message)
import Hackage.Dependency (resolveDependencies, packagesToInstall)
import Hackage.Utils
import Distribution.Package (showPackageId)
import Distribution.Simple.Compiler (Compiler)
......@@ -126,7 +127,7 @@ fetch :: ConfigFlags -> Compiler -> ProgramConfiguration -> [String] -> [Unresol
fetch cfg comp conf _globalArgs deps
= do depTree <- resolveDependencies cfg comp conf deps
case packagesToInstall depTree of
Left missing -> fail $ "Unresolved dependencies: " ++ show missing
Left missing -> fail $ "Unresolved dependencies: " ++ showDependencies missing
Right pkgs -> do ps <- filterM (fmap not . isFetched cfg) $ map fst pkgs
mapM_ (fetchPackage cfg) ps
......
......@@ -16,12 +16,12 @@ import Hackage.Config
import Hackage.Dependency
import Hackage.Fetch
import Hackage.Types
import Hackage.Utils
import Distribution.Package (showPackageId)
import Distribution.ParseUtils (showDependency)
import Distribution.Simple.Compiler (Compiler)
import Distribution.Simple.Program (ProgramConfiguration)
import Distribution.Version (Dependency)
import Data.List (intersperse, nubBy)
import Text.Printf (printf)
......@@ -62,6 +62,3 @@ infoPkg cfg (Available dep pkg opts deps)
infoPkg _ (Unavailable dep)
= do printf " Requested: %s\n" (show $ showDependency dep)
printf " Not available!\n\n"
showDependencies :: [Dependency] -> String
showDependencies = concat . intersperse ", " . map (show . showDependency)
......@@ -29,6 +29,7 @@ import Hackage.Fetch (fetchPackage)
import Hackage.Tar (extractTarGzFile)
import Hackage.Types (ConfigFlags(..), UnresolvedDependency(..)
, PkgInfo(..))
import Hackage.Utils
import Distribution.Simple.Compiler (Compiler(..))
import Distribution.Simple.InstallDirs (InstallDirs(..), absoluteInstallDirs)
......@@ -56,7 +57,7 @@ installLocalPackage cfg comp conf globalArgs =
desc <- readPackageDescription (configVerbose cfg) cabalFile
resolvedDeps <- resolveDependenciesLocal cfg comp conf desc globalArgs
case packagesToInstall resolvedDeps of
Left missing -> fail $ "Unresolved dependencies: " ++ show missing
Left missing -> fail $ "Unresolved dependencies: " ++ showDependencies missing
Right pkgs -> installPackages cfg comp globalArgs pkgs
let pkgId = package (packageDescription desc)
installUnpackedPkg cfg comp globalArgs pkgId [] Nothing
......@@ -65,7 +66,7 @@ installRepoPackages :: ConfigFlags -> Compiler -> ProgramConfiguration -> [Strin
installRepoPackages cfg comp conf globalArgs deps =
do resolvedDeps <- resolveDependencies cfg comp conf deps
case packagesToInstall resolvedDeps of
Left missing -> fail $ "Unresolved dependencies: " ++ show missing
Left missing -> fail $ "Unresolved dependencies: " ++ showDependencies missing
Right [] -> message cfg normal "All requested packages already installed. Nothing to do."
Right pkgs -> installPackages cfg comp globalArgs pkgs
......
......@@ -2,10 +2,12 @@ module Hackage.Utils where
import Distribution.Compat.ReadP (ReadP, readP_to_S, pfail, get, look, choice)
import Distribution.ParseUtils
import Distribution.Version
import Control.Exception
import Control.Monad (foldM, guard)
import Data.Char (isSpace, toLower)
import Data.List (intersperse)
import Data.Maybe (listToMaybe)
import System.IO.Error (isDoesNotExistError)
import Text.PrettyPrint.HughesPJ (Doc, render, vcat, text, (<>), (<+>))
......@@ -79,3 +81,7 @@ stringNoCase this = look >>= scan this
scan [] _ = return this
scan (x:xs) (y:ys) | toLower x == toLower y = get >> scan xs ys
scan _ _ = pfail
showDependencies :: [Dependency] -> String
showDependencies = concat . intersperse ", " . map (show . showDependency)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment