Skip to content

Commit

Permalink
Ignore .ghci files while querying project GHC (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
fendor committed Mar 7, 2022
1 parent 2d9022b commit bb78846
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/HIE/Bios/Cradle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -646,9 +646,15 @@ cabalBuildDir workDir = do
-- If cabal can not figure it out, a 'CradleError' is returned.
cabalGhcDirs :: FilePath -> CradleLoadResultT IO (FilePath, FilePath)
cabalGhcDirs workDir = do
libdir <- readProcessWithCwd_ workDir "cabal" ["exec", "-v0", "--", "ghc", "--print-libdir"] ""
exe <- readProcessWithCwd_ workDir "cabal"
["exec", "-v0", "--", "ghc", "-package-env=-", "-e", "do e <- System.Environment.getExecutablePath ; System.IO.putStr e"] ""
libdir <- readProcessWithCwd_ workDir "cabal" ["exec", "-v0", "--", "ghc", "--print-libdir"] ""
exe <- readProcessWithCwd_ workDir "cabal"
-- DON'T TOUCH THIS CODE
-- This works with 'NoImplicitPrelude', with 'RebindableSyntax' and other shenanigans.
-- @-package-env=-@ doesn't work with ghc prior 8.4.x
[ "exec", "-v0", "--" , "ghc", "-package-env=-", "-ignore-dot-ghci", "-e"
, "Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath)"
]
""
pure (trimEnd exe, trimEnd libdir)

cabalAction :: FilePath -> Maybe String -> LoggingFunction -> FilePath -> CradleLoadResultT IO ComponentOptions
Expand Down
5 changes: 5 additions & 0 deletions tests/projects/simple-cabal/.ghci
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- This file is intentional
--
-- Issue: https://github.com/haskell/hie-bios/issues/336
--
:set +t

0 comments on commit bb78846

Please sign in to comment.