Skip to content

Commit a86f2cb

Browse files
committed
Ignore .ghci files while querying project GHC
1 parent 2d9022b commit a86f2cb

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/HIE/Bios/Cradle.hs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -646,9 +646,15 @@ cabalBuildDir workDir = do
646646
-- If cabal can not figure it out, a 'CradleError' is returned.
647647
cabalGhcDirs :: FilePath -> CradleLoadResultT IO (FilePath, FilePath)
648648
cabalGhcDirs workDir = do
649-
libdir <- readProcessWithCwd_ workDir "cabal" ["exec", "-v0", "--", "ghc", "--print-libdir"] ""
650-
exe <- readProcessWithCwd_ workDir "cabal"
651-
["exec", "-v0", "--", "ghc", "-package-env=-", "-e", "do e <- System.Environment.getExecutablePath ; System.IO.putStr e"] ""
649+
libdir <- readProcessWithCwd_ workDir "cabal" ["exec", "-v0", "--", "ghc", "--print-libdir"] ""
650+
exe <- readProcessWithCwd_ workDir "cabal"
651+
-- DON'T TOUCH THIS CODE
652+
-- This works with 'NoImplicitPrelude', with 'RebindableSyntax' and other shenanigans.
653+
-- @-package-env=-@ doesn't work with ghc prior 8.4.x
654+
[ "exec", "-v0", "--" , "ghc", "-package-env=-", "-ignore-dot-ghci", "-e"
655+
, "Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath)"
656+
]
657+
""
652658
pure (trimEnd exe, trimEnd libdir)
653659

654660
cabalAction :: FilePath -> Maybe String -> LoggingFunction -> FilePath -> CradleLoadResultT IO ComponentOptions

tests/projects/simple-cabal/.ghci

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- This file is intentional
2+
--
3+
-- Issue: https://github.com/haskell/hie-bios/issues/336
4+
--
5+
:set +t

0 commit comments

Comments
 (0)