Haskell 堆栈构建结果为;输出用-o重定向,但由于没有主模块,因此不会生成输出。”;

Haskell 堆栈构建结果为;输出用-o重定向,但由于没有主模块,因此不会生成输出。”;,haskell,cabal,haskell-stack,Haskell,Cabal,Haskell Stack,谷歌搜索这个错误时没有看到任何相关结果,所以我想我会发布它 stack build Building all executables for `gitchapter' once. After a successful build of all of them, only specified executables will be rebuilt. gitchapter-0.1.0.0: build (exe) Preprocessing executable 'app' for gitchapt

谷歌搜索这个错误时没有看到任何相关结果,所以我想我会发布它

stack build
Building all executables for `gitchapter' once. After a successful build of all of them, only specified executables will be rebuilt.
gitchapter-0.1.0.0: build (exe)
Preprocessing executable 'app' for gitchapter-0.1.0.0..
Building executable 'app' for gitchapter-0.1.0.0..
Preprocessing executable 'test' for gitchapter-0.1.0.0..
Warning: Enabling workaround for Main module 'Main' listed in 'other-modules'
Building executable 'test' for gitchapter-0.1.0.0..
illegaly!

<no location info>: error:
    output was redirected with -o, but no output will be generated
because there is no Main module.


--  While building custom Setup.hs for package gitchapter-0.1.0.0 using:
      /home/chris/.stack/setup-exe-cache/x86_64-linux-nopie/Cabal-simple_mPHDZzAJ_2.0.1.0_ghc-8.2.2 --builddir=.stack-work/dist/x86_64-linux-nopie/Cabal-2.0.1.0 build exe:app exe:test --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
你需要设置

executable test
  ghc-options:  -main-is Test

在你的阴谋集团档案里

我认为您需要添加
ghc选项:-main是XXX
,其中
XXX
是模块的名称,例如
Test
。这就是解决方案!非常感谢。请随意将其作为答案发布。问题涉及:哇,在意识到您给出的
main is
main is:Test.hs
不同之前,我看了大约4次。谢谢更改由
hpack
生成的
.cabal
文件是错误的做法。改为更改
package.yaml
。@willbush但我真的很惊讶,你必须直接“注入”信息到
ghc
,而不是告诉阴谋集团传递信息。
executable test
  ghc-options:  -main-is Test