Skip to content

Commit 88aaf59

Browse files
committed
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
1 parent d505c86 commit 88aaf59

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Other enhancements:
1616
Bug fixes:
1717

1818
* When using the `STACK_YAML` env var with Docker, make the path absolute.
19+
* Fix the problem of `stack repl foo:test:bar` failing without a project
20+
build before that. See
21+
[#5213](https://github.com/commercialhaskell/stack/issues/5213)
1922

2023
* Fix `stack sdist` introducing unneded sublibrary syntax when using
2124
pvp-bounds. See

src/Stack/Ghci.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,13 @@ ghci opts@GhciOpts{..} = do
183183
-- need is the location of main modules, not the rest.
184184
pkgs0 <- getGhciPkgInfos installMap addPkgs (fmap fst mfileTargets) pkgDescs
185185
figureOutMainFile bopts mainIsTargets localTargets pkgs0
186+
let pkgTargets pn targets =
187+
case targets of
188+
TargetAll _ -> [T.pack (packageNameString pn)]
189+
TargetComps comps -> [renderPkgComponent (pn, c) | c <- toList comps]
186190
-- Build required dependencies and setup local packages.
187-
buildDepsAndInitialSteps opts (map (T.pack . packageNameString . fst) localTargets)
191+
buildDepsAndInitialSteps opts $
192+
concatMap (\(pn, (_, t)) -> pkgTargets pn t) localTargets
188193
targetWarnings localTargets nonLocalTargets mfileTargets
189194
-- Load the list of modules _after_ building, to catch changes in
190195
-- unlisted dependencies (#1180)

0 commit comments

Comments
 (0)