Skip to content

Commit

Permalink
Merge pull request #4127 from qrilka/config-yaml-for-allow-newer
Browse files Browse the repository at this point in the history
Point to user's config.yaml when advising 'allow-newer: true'
  • Loading branch information
mihaimaruseac authored Jul 5, 2018
2 parents 735240f + 12e24da commit 5b3e746
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ Other enhancements:
download from a user other than `commercialstack` on Github, and can be prefixed
with the service `github:`, `gitlab:`, or `bitbucket:`.
* Switch to `githash` to include some unmerged bugfixes in `gitrev`
* [#3685](https://github.com/commercialhaskell/stack/issues/3685)
Suggestion to add `'allow-newer': true` now shows path to user config
file where this flag should be put into

Bug fixes:

Expand Down
8 changes: 5 additions & 3 deletions src/Stack/Build/ConstructPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ constructPlan ls0 baseConfigOpts0 locals extraToBuild0 localDumpPkgs loadPackage
else do
planDebug $ show errs
stackYaml <- view stackYamlL
prettyErrorNoIndent $ pprintExceptions errs stackYaml parents (wanted ctx)
stackRoot <- view stackRootL
prettyErrorNoIndent $ pprintExceptions errs stackYaml stackRoot parents (wanted ctx)
throwM $ ConstructPlanFailed "Plan construction failed."
where
hasBaseInDeps bconfig =
Expand Down Expand Up @@ -967,10 +968,11 @@ data BadDependency
pprintExceptions
:: [ConstructPlanException]
-> Path Abs File
-> Path Abs Dir
-> ParentMap
-> Set PackageName
-> AnsiDoc
pprintExceptions exceptions stackYaml parentMap wanted =
pprintExceptions exceptions stackYaml stackRoot parentMap wanted =
mconcat $
[ flow "While constructing the build plan, the following exceptions were encountered:"
, line <> line
Expand All @@ -980,7 +982,7 @@ pprintExceptions exceptions stackYaml parentMap wanted =
, line <> line
] ++
(if not onlyHasDependencyMismatches then [] else
[ " *" <+> align (flow "Set 'allow-newer: true' to ignore all version constraints and build anyway.")
[ " *" <+> align (flow "Set 'allow-newer: true' in " <+> toAnsiDoc (display (defaultUserConfigPath stackRoot)) <+> "to ignore all version constraints and build anyway.")
, line <> line
]
) ++
Expand Down
23 changes: 23 additions & 0 deletions test/integration/tests/3685-config-yaml-for-allow-newer/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Control.Monad (unless)
import Data.List (isInfixOf)
import StackTest
import System.Directory

main :: IO ()
main = do
stack ["init", defaultResolverArg]
(_, stdErr) <- stackStderr ["install", "intero-0.1.23"]
-- here we check stderr for 'allow-newer: true' and
-- config.yaml sitting either on the same line or on
-- two consecutive lines
let errLines = lines stdErr
hasNewer l = "'allow-newer: true'" `isInfixOf` l
withNewer = map hasNewer errLines
userConfig = "config.yaml"
hasConfigForAllowNewer prevNewer l =
(prevNewer || hasNewer l) &&
userConfig `isInfixOf` l
hasProperLines =
or $ zipWith hasConfigForAllowNewer (False:withNewer) errLines
unless hasProperLines $
error $ "Not stderr lines with 'allow-newer: true' and " ++ userConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: files
version: 0.1.0.0
build-type: Simple
cabal-version: >= 2.0

library
exposed-modules: Src
hs-source-dirs: src
build-depends: base
default-language: Haskell2010
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Src where

-- | A function of the main library
funMainLib :: Int -> Int
funMainLib = succ

0 comments on commit 5b3e746

Please sign in to comment.