Skip to content

Commit 2a95c77

Browse files
committed
detect missing extra-deps missing from indices
* it should now detect typos commercialhaskell#1521 (package suggestions will be added in another PR)
1 parent e7b331f commit 2a95c77

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

src/Stack/Build/Source.hs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,15 +439,24 @@ extendExtraDeps :: (MonadThrow m, MonadReader env m, HasBuildConfig env)
439439
-> Map PackageName Version -- ^ latest versions in indices
440440
-> m (Map PackageName Version) -- ^ new extradeps
441441
extendExtraDeps extraDeps0 cliExtraDeps unknowns latestVersion
442-
| null errs = return $ Map.unions $ extraDeps1 : unknowns'
442+
| null errs && null missing = return $ Map.unions $ extraDeps1 : unknowns'
443443
| otherwise = do
444444
bconfig <- asks getBuildConfig
445+
446+
unless (null missing) $
447+
throwM $ UnknownPackageIdentifiers
448+
(Set.fromList $ map fromTuple $ Map.toList missing)
449+
""
450+
445451
throwM $ UnknownTargets
446452
(Set.fromList errs)
447453
Map.empty -- TODO check the cliExtraDeps for presence in index
448454
(bcStackYaml bconfig)
449455
where
450-
extraDeps1 = Map.union extraDeps0 cliExtraDeps
456+
(missing, extraDeps1) =
457+
Map.partitionWithKey missingFromIndex $ Map.union extraDeps0 cliExtraDeps
458+
459+
missingFromIndex name _ = isNothing $ Map.lookup name latestVersion
451460

452461
(errs, unknowns') = partitionEithers $ map addUnknown $ Set.toList unknowns
453462
addUnknown pn =

src/Stack/Fetch.hs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ data FetchException
8686
| Couldn'tReadPackageTarball FilePath SomeException
8787
| UnpackDirectoryAlreadyExists (Set FilePath)
8888
| CouldNotParsePackageSelectors [String]
89-
| UnknownPackageNames (Set PackageName)
90-
| UnknownPackageIdentifiers (Set PackageIdentifier) String
9189
deriving Typeable
9290
instance Exception FetchException
9391

@@ -110,13 +108,6 @@ instance Show FetchException where
110108
show (CouldNotParsePackageSelectors strs) =
111109
"The following package selectors are not valid package names or identifiers: " ++
112110
intercalate ", " strs
113-
show (UnknownPackageNames names) =
114-
"The following packages were not found in your indices: " ++
115-
intercalate ", " (map packageNameString $ Set.toList names)
116-
show (UnknownPackageIdentifiers idents suggestions) =
117-
"The following package identifiers were not found in your indices: " ++
118-
intercalate ", " (map packageIdentifierString $ Set.toList idents) ++
119-
(if null suggestions then "" else "\n" ++ suggestions)
120111

121112
-- | Fetch packages into the cache without unpacking
122113
fetchPackages :: (MonadIO m, MonadBaseControl IO m, MonadReader env m, HasHttpManager env, HasConfig env, MonadThrow m, MonadLogger m, MonadCatch m)

src/Stack/Types/Package.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ data PackageException
5050
| PackageNoCabalFileFound (Path Abs Dir)
5151
| PackageMultipleCabalFilesFound (Path Abs Dir) [Path Abs File]
5252
| MismatchedCabalName (Path Abs File) PackageName
53+
| UnknownPackageNames (Set PackageName)
54+
| UnknownPackageIdentifiers (Set PackageIdentifier) String
5355
deriving Typeable
5456
instance Exception PackageException
5557
instance Show PackageException where
@@ -77,6 +79,13 @@ instance Show PackageException where
7779
, ".cabal\n"
7880
, "For more information, see: https://github.com/commercialhaskell/stack/issues/317"
7981
]
82+
show (UnknownPackageNames names) =
83+
"The following packages were not found in your indices: " ++
84+
intercalate ", " (map packageNameString $ Set.toList names)
85+
show (UnknownPackageIdentifiers idents suggestions) =
86+
"The following package identifiers were not found in your indices: " ++
87+
intercalate ", " (map packageIdentifierString $ Set.toList idents) ++
88+
(if null suggestions then "" else "\n" ++ suggestions)
8089

8190
-- | Some package info.
8291
data Package =

0 commit comments

Comments
 (0)