haskellghccabalhaskell-stackghci

Multiple files use the same module name:


when I type stack run I get no error message but when I type stack ghci I get this error about multiple files use the same name , how I can solve it ?

(base) wejden@wejdenaydi:~/wejden$ stack ghci
Using main module: 1. Package `wejden' component wejden:exe:wejden-exe with main-is file: /home/wejden/wejden/app/Main.hs
Building all executables for `wejden' once. After a successful build of all of them, only specified executables will be rebuilt.
wejden> configure (lib + exe)
Configuring wejden-0.1.0.0...
wejden> initial-build-steps (lib + exe)
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Configuring GHCi with the following packages: wejden

* * * * * * * *

Warning: Multiple files use the same module name:
         * Paths_wejden found at the following paths
           * /home/wejden/wejden/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/autogen/Paths_wejden.hs (wejden:lib)
           * /home/wejden/wejden/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/wejden-exe/autogen/Paths_wejden.hs (wejden:exe:wejden-exe)
* * * * * * * *

GHCi, version 8.10.4: https://www.haskell.org/ghc/  :? for help
[1 of 3] Compiling Lib              ( /home/wejden/wejden/src/Lib.hs, interpreted )
[2 of 3] Compiling Main             ( /home/wejden/wejden/app/Main.hs, interpreted )
[3 of 3] Compiling Paths_wejden     ( /home/wejden/wejden/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/autogen/Paths_wejden.hs, interpreted )
Ok, three modules loaded.
Loaded GHCi configuration from /tmp/haskell-stack-ghci/f99925e2/ghci-script
*Main Lib Paths_wejden> 

Solution

  • This is a known issue with hpack: https://github.com/commercialhaskell/stack/issues/5439

    In short, add this in your package.yaml, to your executable(s) or your library:

    when:
    - condition: false
      other-modules: Paths_wejden  # your package name here