From 88aaf59efb07bb06333c13b3e796e64ed20c77c7 Mon Sep 17 00:00:00 2001 From: Kirill Zaborsky Date: Fri, 29 May 2020 00:28:48 +0300 Subject: [PATCH] Use target components when starting a REPL This partially fixes #5213 - starting a repl for an exe component doesn't appear to work for some reason --- ChangeLog.md | 3 +++ src/Stack/Ghci.hs | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 48082a3a8c..eaca9a2a9d 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -16,6 +16,9 @@ Other enhancements: Bug fixes: * When using the `STACK_YAML` env var with Docker, make the path absolute. +* Fix the problem of `stack repl foo:test:bar` failing without a project + build before that. See + [#5213](https://github.com/commercialhaskell/stack/issues/5213) * Fix `stack sdist` introducing unneded sublibrary syntax when using pvp-bounds. See diff --git a/src/Stack/Ghci.hs b/src/Stack/Ghci.hs index 34418d4cd2..3e40d46c92 100644 --- a/src/Stack/Ghci.hs +++ b/src/Stack/Ghci.hs @@ -183,8 +183,13 @@ ghci opts@GhciOpts{..} = do -- need is the location of main modules, not the rest. pkgs0 <- getGhciPkgInfos installMap addPkgs (fmap fst mfileTargets) pkgDescs figureOutMainFile bopts mainIsTargets localTargets pkgs0 + let pkgTargets pn targets = + case targets of + TargetAll _ -> [T.pack (packageNameString pn)] + TargetComps comps -> [renderPkgComponent (pn, c) | c <- toList comps] -- Build required dependencies and setup local packages. - buildDepsAndInitialSteps opts (map (T.pack . packageNameString . fst) localTargets) + buildDepsAndInitialSteps opts $ + concatMap (\(pn, (_, t)) -> pkgTargets pn t) localTargets targetWarnings localTargets nonLocalTargets mfileTargets -- Load the list of modules _after_ building, to catch changes in -- unlisted dependencies (#1180)