-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't have "stack solver" suggest --omit-packages #2031
- Loading branch information
Showing
4 changed files
with
46 additions
and
30 deletions.
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
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 |
---|---|---|
|
@@ -54,6 +54,8 @@ module Stack.Types.Config | |
,ApplyGhcOptions(..) | ||
-- ** ConfigException | ||
,ConfigException(..) | ||
-- ** WhichSolverCmd | ||
,WhichSolverCmd(..) | ||
-- ** ConfigMonoid | ||
,ConfigMonoid(..) | ||
-- ** EnvSettings | ||
|
@@ -1076,9 +1078,9 @@ data ConfigException | |
| UnexpectedArchiveContents [Path Abs Dir] [Path Abs File] | ||
| UnableToExtractArchive Text (Path Abs File) | ||
| BadStackVersionException VersionRange | ||
| NoMatchingSnapshot (NonEmpty SnapName) | ||
| forall l. ResolverMismatch (ResolverThat's l) String | ||
| ResolverPartial Resolver String | ||
| NoMatchingSnapshot WhichSolverCmd (NonEmpty SnapName) | ||
| forall l. ResolverMismatch WhichSolverCmd (ResolverThat's l) String | ||
| ResolverPartial WhichSolverCmd Resolver String | ||
| NoSuchDirectory FilePath | ||
| ParseGHCVariantException String | ||
| BadStackRoot (Path Abs Dir) | ||
|
@@ -1133,31 +1135,27 @@ instance Show ConfigException where | |
,"version range specified in stack.yaml (" | ||
, T.unpack (versionRangeText requiredRange) | ||
, ")." ] | ||
show (NoMatchingSnapshot names) = concat | ||
show (NoMatchingSnapshot whichCmd names) = concat $ | ||
[ "None of the following snapshots provides a compiler matching " | ||
, "your package(s):\n" | ||
, unlines $ map (\name -> " - " <> T.unpack (renderSnapName name)) | ||
(NonEmpty.toList names) | ||
, "\nYou can try the following options:\n" | ||
, " - Use '--omit-packages to exclude mismatching package(s).\n" | ||
, " - Use '--resolver' to specify a matching snapshot/resolver\n" | ||
, showOptions whichCmd | ||
] | ||
show (ResolverMismatch resolver errDesc) = concat | ||
show (ResolverMismatch whichCmd resolver errDesc) = concat | ||
[ "Resolver '" | ||
, T.unpack (resolverName resolver) | ||
, "' does not have a matching compiler to build some or all of your " | ||
, "package(s).\n" | ||
, errDesc | ||
, "\nHowever, you can try '--omit-packages to exclude mismatching " | ||
, "package(s)." | ||
, showOptions whichCmd | ||
] | ||
show (ResolverPartial resolver errDesc) = concat | ||
show (ResolverPartial whichCmd resolver errDesc) = concat | ||
[ "Resolver '" | ||
, T.unpack (resolverName resolver) | ||
, "' does not have all the packages to match your requirements.\n" | ||
, unlines $ fmap (" " <>) (lines errDesc) | ||
, "\nHowever, you can try '--solver' to use external packages." | ||
, "\nUse '--omit-packages' if you want to create a config anyway." | ||
, showOptions whichCmd | ||
] | ||
show (NoSuchDirectory dir) = concat | ||
["No directory could be located matching the supplied path: " | ||
|
@@ -1189,6 +1187,20 @@ instance Show ConfigException where | |
] | ||
instance Exception ConfigException | ||
|
||
showOptions :: WhichSolverCmd -> String | ||
showOptions whichCmd = unlines $ ["\nThis may be resolved by:"] ++ options | ||
where | ||
options = | ||
case whichCmd of | ||
IsSolverCmd -> [useResolver] | ||
IsInitCmd -> both | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mgsloan
Author
Contributor
|
||
IsNewCmd -> both | ||
both = [omitPackages, useResolver] | ||
omitPackages = " - Using '--omit-packages to exclude mismatching package(s)." | ||
useResolver = " - Using '--resolver' to specify a matching snapshot/resolver" | ||
|
||
data WhichSolverCmd = IsInitCmd | IsSolverCmd | IsNewCmd | ||
|
||
-- | Helper function to ask the environment and apply getConfig | ||
askConfig :: (MonadReader env m, HasConfig env) => m Config | ||
askConfig = liftM getConfig ask | ||
|
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
Just found it out that
stack init
is no longer suggesting--solver
.Also, the messaging was context sensitive earlier to suggest only the right options e.g.
--resolver
was suggested in NoMatchingSnapshot case only and--solver
was being suggested in the ResolverPartial case.