Skip to content
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

Show resolver being used when stack ghci is invoked outside of a project directory #4521

Merged
merged 13 commits into from
Feb 10, 2019
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ Other enhancements:
* `get-stack` script now works on Windows CI machines of Appveyor,
Travis and Azure Pipelines. See
[#4535](https://github.com/commercialhaskell/stack/issues/4535)/
* Show snapshot being used when `stack ghci` is invoked outside of a project directory. See
[#3651](https://github.com/commercialhaskell/stack/issues/3651)

Bug fixes:

Expand Down
1 change: 1 addition & 0 deletions src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ loadBuildConfig mproject maresolver mcompiler = do
{ smwCompiler = fromMaybe (snapshotCompiler snapshot) mcompiler
, smwProject = packages
, smwDeps = deps
, smwSnapshotName = snapshotName snapshot
}

return BuildConfig
Expand Down
16 changes: 9 additions & 7 deletions src/Stack/Ghci.hs
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,8 @@ ghci opts@GhciOpts{..} = do
pkgs0 <- getGhciPkgInfos installMap addPkgs (fmap fst mfileTargets) pkgDescs
figureOutMainFile bopts mainIsTargets localTargets pkgs0
-- Build required dependencies and setup local packages.
stackYaml <- view stackYamlL
buildDepsAndInitialSteps opts (map (T.pack . packageNameString . fst) localTargets)
targetWarnings stackYaml localTargets nonLocalTargets mfileTargets
targetWarnings localTargets nonLocalTargets mfileTargets
-- Load the list of modules _after_ building, to catch changes in
-- unlisted dependencies (#1180)
pkgs <- getGhciPkgInfos installMap addPkgs (fmap fst mfileTargets) pkgDescs
Expand Down Expand Up @@ -836,13 +835,12 @@ checkForDuplicateModules pkgs = do
pretty fp <+> parens (fillSep (punctuate "," (map displayPkgComponent (S.toList comps))))

targetWarnings
:: HasTerm env
=> Path Abs File
-> [(PackageName, (Path Abs File, Target))]
:: HasBuildConfig env
=> [(PackageName, (Path Abs File, Target))]
-> [PackageName]
-> Maybe (Map PackageName [Path Abs File], [Path Abs File])
-> RIO env ()
targetWarnings stackYaml localTargets nonLocalTargets mfileTargets = do
targetWarnings localTargets nonLocalTargets mfileTargets = do
unless (null nonLocalTargets) $
prettyWarnL
[ flow "Some targets"
Expand All @@ -853,10 +851,14 @@ targetWarnings stackYaml localTargets nonLocalTargets mfileTargets = do
, "."
, flow "It can still be useful to specify these, as they will be passed to ghci via -package flags."
]
when (null localTargets && isNothing mfileTargets) $
when (null localTargets && isNothing mfileTargets) $ do
smWanted <- view $ buildConfigL.to bcSMWanted
stackYaml <- view stackYamlL
prettyNote $ vsep
[ flow "No local targets specified, so a plain ghci will be started with no package hiding or package options."
, ""
, flow $ "You are using snapshot: " ++ T.unpack (smwSnapshotName smWanted)
, ""
, flow "If you want to use package hiding and options, then you can try one of the following:"
, ""
, bulletedList
Expand Down
1 change: 1 addition & 0 deletions src/Stack/Types/SourceMap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ data SMWanted = SMWanted
{ smwCompiler :: !WantedCompiler
, smwProject :: !(Map PackageName ProjectPackage)
, smwDeps :: !(Map PackageName DepPackage)
, smwSnapshotName :: !Text
}

-- | Adds in actual compiler information to 'SMWanted', in particular
Expand Down