Skip to content

Commit

Permalink
Merge pull request #4573 from commercialhaskell/no-error-on-missing-b…
Browse files Browse the repository at this point in the history
…oot-library-revision

Don't error out on missing latest revision while constructing a build plan
  • Loading branch information
dbaynard committed Feb 7, 2019
2 parents a7b07fc + 6e4adc8 commit 4e56620
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/Stack/Build/ConstructPlan.hs
Expand Up @@ -426,9 +426,15 @@ addDep treatAsDep' name = do
askPkgLoc = liftRIO $ do
mrev <- getLatestHackageRevision name version
case mrev of
Nothing -> error $ "No package revision found for: " <> show name
Nothing -> do
-- this could happen for GHC boot libraries missing from Hackage
logWarn $ "No latest package revision found for: " <>
fromString (packageNameString name) <> ", dependency callstack: " <>
displayShow (map packageNameString $ callStack ctx)
return Nothing
Just (_rev, cfKey, treeKey) ->
return $ PLIHackage (PackageIdentifier name version) cfKey treeKey
return . Just $
PLIHackage (PackageIdentifier name version) cfKey treeKey
tellExecutablesUpstream name askPkgLoc loc Map.empty
return $ Right $ ADRFound loc installed
Just (PIOnlySource ps) -> do
Expand All @@ -448,15 +454,21 @@ tellExecutables _name (PSFilePath lp)
-- Ignores ghcOptions because they don't matter for enumerating
-- executables.
tellExecutables name (PSRemote pkgloc _version _fromSnaphot cp) =
tellExecutablesUpstream name (pure pkgloc) Snap (cpFlags cp)

tellExecutablesUpstream :: PackageName -> M PackageLocationImmutable -> InstallLocation -> Map FlagName Bool -> M ()
tellExecutablesUpstream name retrievePkgloc loc flags = do
tellExecutablesUpstream name (pure $ Just pkgloc) Snap (cpFlags cp)

tellExecutablesUpstream ::
PackageName
-> M (Maybe PackageLocationImmutable)
-> InstallLocation
-> Map FlagName Bool
-> M ()
tellExecutablesUpstream name retrievePkgLoc loc flags = do
ctx <- ask
when (name `Set.member` wanted ctx) $ do
pkgloc <- retrievePkgloc
p <- loadPackage ctx pkgloc flags []
tellExecutablesPackage loc p
mPkgLoc <- retrievePkgLoc
forM_ mPkgLoc $ \pkgLoc -> do
p <- loadPackage ctx pkgLoc flags []
tellExecutablesPackage loc p

tellExecutablesPackage :: InstallLocation -> Package -> M ()
tellExecutablesPackage loc p = do
Expand Down

0 comments on commit 4e56620

Please sign in to comment.