diff --git a/ChangeLog.md b/ChangeLog.md index 2c5fdb2b47..7033542d89 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -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: diff --git a/src/Stack/Config.hs b/src/Stack/Config.hs index 9292aed60a..9bd6699130 100644 --- a/src/Stack/Config.hs +++ b/src/Stack/Config.hs @@ -645,6 +645,7 @@ loadBuildConfig mproject maresolver mcompiler = do { smwCompiler = fromMaybe (snapshotCompiler snapshot) mcompiler , smwProject = packages , smwDeps = deps + , smwSnapshotName = snapshotName snapshot } return BuildConfig diff --git a/src/Stack/Ghci.hs b/src/Stack/Ghci.hs index e42e118a1f..4d9e606664 100644 --- a/src/Stack/Ghci.hs +++ b/src/Stack/Ghci.hs @@ -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 @@ -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" @@ -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 diff --git a/src/Stack/Types/SourceMap.hs b/src/Stack/Types/SourceMap.hs index d36a297cbf..eee6c63b3b 100644 --- a/src/Stack/Types/SourceMap.hs +++ b/src/Stack/Types/SourceMap.hs @@ -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