-
Notifications
You must be signed in to change notification settings - Fork 843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cabal-hash revision info when displaying recommended packages when failing to construct buildplan #4068
Merged
snoyberg
merged 3 commits into
commercialhaskell:master
from
tdietert:recommended-packages-with-rev-info
Jun 7, 2018
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ import Stack.Prelude hiding (Display (..)) | |
import Control.Monad.RWS.Strict hiding ((<>)) | ||
import Control.Monad.State.Strict (execState) | ||
import qualified Data.HashSet as HashSet | ||
import qualified Data.HashMap.Strict as HashMap | ||
import Data.List | ||
import qualified Data.Map.Strict as M | ||
import qualified Data.Map.Strict as Map | ||
|
@@ -135,7 +136,7 @@ data Ctx = Ctx | |
, ctxEnvConfig :: !EnvConfig | ||
, callStack :: ![PackageName] | ||
, extraToBuild :: !(Set PackageName) | ||
, getVersions :: !(PackageName -> IO (Set Version)) | ||
, getVersions :: !(PackageName -> IO (HashMap Version (Maybe CabalHash))) | ||
, wanted :: !(Set PackageName) | ||
, localNames :: !(Set PackageName) | ||
} | ||
|
@@ -623,17 +624,22 @@ addPackageDeps treatAsDep package = do | |
deps' <- packageDepsWithTools package | ||
deps <- forM (Map.toList deps') $ \(depname, (range, depType)) -> do | ||
eres <- addDep treatAsDep depname | ||
let getLatestApplicable = do | ||
vs <- liftIO $ getVersions ctx depname | ||
return (latestApplicableVersion range vs) | ||
let getLatestApplicableVersionAndRev = do | ||
vsAndRevs <- liftIO $ getVersions ctx depname | ||
let vs = Set.fromList (HashMap.keys vsAndRevs) | ||
case latestApplicableVersion range vs of | ||
Nothing -> pure Nothing | ||
Just lappVer -> do | ||
let mlappRev = join (HashMap.lookup lappVer vsAndRevs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice join! |
||
pure $ (lappVer,) <$> mlappRev | ||
case eres of | ||
Left e -> do | ||
addParent depname range Nothing | ||
let bd = | ||
case e of | ||
UnknownPackage name -> assert (name == depname) NotInBuildPlan | ||
_ -> Couldn'tResolveItsDependencies (packageVersion package) | ||
mlatestApplicable <- getLatestApplicable | ||
mlatestApplicable <- getLatestApplicableVersionAndRev | ||
return $ Left (depname, (range, mlatestApplicable, bd)) | ||
Right adr | depType == AsLibrary && not (adrHasLibrary adr) -> | ||
return $ Left (depname, (range, Nothing, HasNoLibrary)) | ||
|
@@ -677,7 +683,7 @@ addPackageDeps treatAsDep package = do | |
ADRFound loc (Library ident gid _) -> return $ Right | ||
(Set.empty, Map.singleton ident gid, loc) | ||
else do | ||
mlatestApplicable <- getLatestApplicable | ||
mlatestApplicable <- getLatestApplicableVersionAndRev | ||
return $ Left (depname, (range, mlatestApplicable, DependencyMismatch $ adrVersion adr)) | ||
case partitionEithers deps of | ||
-- Note that the Monoid for 'InstallLocation' means that if any | ||
|
@@ -939,8 +945,9 @@ data ConstructPlanException | |
|
||
deriving instance Ord VersionRange | ||
|
||
-- | For display purposes only, Nothing if package not found | ||
type LatestApplicableVersion = Maybe Version | ||
-- | The latest applicable version and it's latest cabal file revision. | ||
-- For display purposes only, Nothing if package not found | ||
type LatestApplicableVersion = Maybe (Version, CabalHash) | ||
|
||
-- | Reason why a dependency was not used | ||
data BadDependency | ||
|
@@ -977,7 +984,7 @@ pprintExceptions exceptions stackYaml parentMap wanted = | |
[ " *" <+> align (flow "Consider trying 'stack solver', which uses the cabal-install solver to attempt to find some working build configuration. This can be convenient when dealing with many complicated constraint errors, but results may be unpredictable.") | ||
, line <> line | ||
] ++ addExtraDepsRecommendations | ||
|
||
where | ||
exceptions' = nubOrd exceptions | ||
|
||
|
@@ -1004,13 +1011,16 @@ pprintExceptions exceptions stackYaml parentMap wanted = | |
Map.unions $ map go $ Map.toList m | ||
where | ||
-- TODO: Likely a good idea to distinguish these to the user. In particular, for DependencyMismatch | ||
go (name, (_range, Just version, NotInBuildPlan)) = | ||
Map.singleton name version | ||
go (name, (_range, Just version, DependencyMismatch{})) = | ||
Map.singleton name version | ||
go (name, (_range, Just (version,cabalHash), NotInBuildPlan)) = | ||
Map.singleton name (version,cabalHash) | ||
go (name, (_range, Just (version,cabalHash), DependencyMismatch{})) = | ||
Map.singleton name (version, cabalHash) | ||
go _ = Map.empty | ||
pprintExtra (name, version) = | ||
fromString (concat ["- ", packageNameString name, "-", versionString version]) | ||
pprintExtra (name, (version, cabalHash)) = | ||
let cfInfo = CFIHash Nothing cabalHash | ||
packageId = PackageIdentifier name version | ||
packageIdRev = PackageIdentifierRevision packageId cfInfo | ||
in fromString $ packageIdentifierRevisionString packageIdRev | ||
|
||
allNotInBuildPlan = Set.fromList $ concatMap toNotInBuildPlan exceptions' | ||
toNotInBuildPlan (DependencyPlanFailures _ pDeps) = | ||
|
@@ -1091,11 +1101,11 @@ pprintExceptions exceptions stackYaml parentMap wanted = | |
| isNothing mversion -> | ||
flow "(no package with that name found, perhaps there is a typo in a package's build-depends or an omission from the stack.yaml packages list?)" | ||
| otherwise -> "" | ||
Just la | ||
| mlatestApplicable == mversion -> softline <> | ||
Just (laVer, _) | ||
| Just laVer == mversion -> softline <> | ||
flow "(latest matching version is specified)" | ||
| otherwise -> softline <> | ||
flow "(latest matching version is" <+> styleGood (display la) <> ")" | ||
flow "(latest matching version is" <+> styleGood (display laVer) <> ")" | ||
|
||
-- | Get the shortest reason for the package to be in the build plan. In | ||
-- other words, trace the parent dependencies back to a 'wanted' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a note to the ChangeLog about the change and which issue it resolves?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the changelog 👍