diff --git a/src/HIE/Bios/Cradle.hs b/src/HIE/Bios/Cradle.hs index bc86f38ea..d422f0d77 100644 --- a/src/HIE/Bios/Cradle.hs +++ b/src/HIE/Bios/Cradle.hs @@ -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 diff --git a/tests/projects/simple-cabal/.ghci b/tests/projects/simple-cabal/.ghci new file mode 100644 index 000000000..73007d4f1 --- /dev/null +++ b/tests/projects/simple-cabal/.ghci @@ -0,0 +1,5 @@ +-- This file is intentional +-- +-- Issue: https://github.com/haskell/hie-bios/issues/336 +-- +:set +t