多个文件使用相同的模块名称:

问题描述 投票:0回答:3

当我输入 stack run 时,我没有收到错误消息,但是当我输入 stack ghci 时,我收到有关多个文件使用相同名称的错误,我该如何解决它?

(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> 
haskell ghc cabal haskell-stack ghci
3个回答
16
投票

对于那些像我一样需要非常具体说明的人,这里是:

executables:        
  mypkgname-exe:        
    main:                Main.hs        
    source-dirs:         app        
    ghc-options:        
    - -threaded        
    - -rtsopts        
    - -with-rtsopts=-N        
    dependencies:        
    - stocks        
    when:        
    - condition: false        
      other-modules: Paths_mypkgname

其中

mypkgname
需要替换为您的包名称。我发布此内容是因为在我第一次尝试时,我将
when
子句放在了错误的位置。


12
投票

这是

hpack
的已知问题:https://github.com/commercialhaskell/stack/issues/5439

简而言之,将其添加到您的

package.yaml
中,添加到您的可执行文件或库中:

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

0
投票

使用较新的堆栈 (>= 2.13.1),您可以通过将以下内容添加到

package.yaml
来抑制该消息。 (参见https://github.com/commercialhaskell/stack/issues/5439#issuecomment-1973929613

spec-version: 0.36.0
© www.soinside.com 2019 - 2024. All rights reserved.