Search code examples
haskellhaskell-stackghci

Error: module ‘main:Course’ is defined in multiple files: src/Course.hs


I'm trying to start working on https://github.com/system-f/fp-course. After running stack ghci, it finishes with:

...
[51 of 51] Compiling Test.Loader      ( src/Test/Loader.hs, interpreted )
Ok, 51 modules loaded.
Loaded GHCi configuration from /home/lpied/haskell/fp-course/.ghci

<no location info>: error:
    module ‘main:Course’ is defined in multiple files: src/Course.hs
                                                       src/Course.hs
Failed, 51 modules loaded.
Loaded GHCi configuration from /tmp/haskell-stack-ghci/75d10d48/ghci-script

Any idea why it's complaining that the module is defined in the same file (src/Course.hs)?


Solution

  • Can you try using stack exec ghci instead? stack ghci is probably recognizing the src directory and adding -isrc to the ghci command line, and then the .ghci file in the course root directory is also adding -isrc to the ghci command line. GHC probably doesn't de-duplicate its search path, so it acts like you have two separate directories which both happen to be named src.