Skip to content

ghci regression: `:add` Exception ExitFailure with GHC >= 9.4

Summary

Running ghci with a script file and in -e mode fails to load modules in the ghci script.

Steps to reproduce

  1. ghci_script
:add *Main.hs
:module + *Main
  1. Main.hs
main :: IO ()
main = do
  putStrLn "test"
  1. run ghci -ghci-script ghci_repl -e :main
*** Exception: ExitFailure 1

<no location info>: error:
    Could not find module ‘Main’
    It is not a module in the current program, or in any known package.

<interactive>:0:53: error:
    Variable not in scope: main :: IO a0
    Suggested fix: Perhaps use ‘min’ (imported from Prelude)

Where, apparently, the *** Exception: ExitFailure 1 seems to be caused by the :add command and the other error messages are subsequently caused by this.

When running without the -e :main flag, it drops into the repl and I can call :main successfully:

GHCi, version 9.6.2: https://www.haskell.org/ghc/  :? for help
[1 of 2] Compiling Main             ( Main.hs, interpreted )
Ok, one module loaded.
Main.hs
Loaded GHCi configuration from ghci_repl
ghci> :main
test
ghci>

Also, when using :load * instead of :add * it works...

Expected behavior

Using :add should work together with the -e flag, like it used to in previous releases.

Environment

  • GHC version used: 9.4.2 - 9.4.6, 9.6.2

Optional:

  • Operating System: linux / nixOS & ubuntu with GHC bindist
  • System Architecture: x86_amd64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information