Skip to content

Commit 217fa42

Browse files
Merge pull request #4600 from nh2/ambiguous-load-easy-component-copy-paste
stack ghci: Make shown options easily copy-pastable.
2 parents ac71e9b + bf5288a commit 217fa42

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ Other enhancements:
8383
* Stack parses and respects the `preferred-versions` information from
8484
Hackage for choosing latest version of a package in some cases,
8585
e.g. `stack unpack packagename`.
86+
* The components output in the `The main module to load is ambiguous` message
87+
now include package names so they can be more easily copy-pasted.
8688
* Git repos are shared across multiple projects. See
8789
[#3551](https://github.com/commercialhaskell/stack/issues/3551)
8890
* Use en_US.UTF-8 locale by default in pure Nix mode so programs won't

src/Stack/Ghci.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,10 +561,13 @@ figureOutMainFile bopts mainIsTargets targets0 packages = do
561561
wantedPackageComponents bopts target (ghciPkgPackage pkg)
562562
renderCandidate c@(pkgName,namedComponent,mainIs) =
563563
let candidateIndex = T.pack . show . (+1) . fromMaybe 0 . elemIndex c
564+
pkgNameText = T.pack (packageNameString pkgName)
564565
in candidateIndex candidates <> ". Package `" <>
565-
T.pack (packageNameString pkgName) <>
566+
pkgNameText <>
566567
"' component " <>
567-
renderComp namedComponent <>
568+
-- This is the format that can be directly copy-pasted as
569+
-- an argument to `stack ghci`.
570+
pkgNameText <> ":" <> renderComp namedComponent <>
568571
" with main-is file: " <>
569572
T.pack (toFilePath mainIs)
570573
candidateIndices = take (length candidates) [1 :: Int ..]

0 commit comments

Comments
 (0)