stack build results in “output was redirected with -o, but no output will be generated because there is no Main module.”

孤街浪徒 提交于 2020-01-11 03:50:07

问题


Didn't see any relevant result when google searching for this error so thought I'd post it.

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

It definitely is related to the 'test' executable definition - as if I remove this, it completes the stack build successfully - but without the required test executable.

gitchapter.cabal

-- This file has been generated from package.yaml by hpack version 0.28.2.
--
-- see: https://github.com/sol/hpack
--
-- hash: a3e4a735ee8304dd50f5af53a64d7b639894cbcc24ba01d0171a588e67455018

name:           gitchapter
version:        0.1.0.0
author:         Chris Stryczynski
maintainer:     Chris Stryczynski
license:        BSD3
license-file:   LICENSE
build-type:     Simple
cabal-version:  >= 1.10

executable app
  main-is: Main.hs
  other-modules:
      BlogLiterately
      Example
      FileSection
      GHCi
      GHCiSession
      Git
      GitTextPartial
      Hart
      Operations
      Operations.Parsers
      QuasiText
      Render
      Section
      Test
      Paths_gitchapter
  hs-source-dirs:
      src
  build-depends:
      HUnit
    , QuickCheck
    , base >=4.9 && <4.11
    , directory
    , extra
    , filepath
    , foldl
    , mtl
    , optparse-applicative
    , pandoc-include-code
    , parsec
    , pretty-simple
    , process
    , regex-pcre
    , regex-posix
    , safe
    , string-conversions
    , system-filepath
    , template-haskell
    , text
    , transformers
    , turtle
    , unix
    , unordered-containers
  default-language: Haskell2010

executable test
  main-is: Test.hs
  other-modules:
      BlogLiterately
      Example
      FileSection
      GHCi
      GHCiSession
      Git
      GitTextPartial
      Hart
      Main
      Operations
      Operations.Parsers
      QuasiText
      Render
      Section
      Paths_gitchapter
  hs-source-dirs:
      src
  build-depends:
      HUnit
    , QuickCheck
    , base >=4.9 && <4.11
    , directory
    , extra
    , filepath
    , foldl
    , mtl
    , optparse-applicative
    , pandoc-include-code
    , parsec
    , pretty-simple
    , process
    , regex-pcre
    , regex-posix
    , safe
    , string-conversions
    , system-filepath
    , template-haskell
    , text
    , transformers
    , turtle
    , unix
    , unordered-containers
  default-language: Haskell2010

回答1:


You need to set

executable test
  ghc-options:  -main-is Test

in your cabal file.



来源:https://stackoverflow.com/questions/50659327/stack-build-results-in-output-was-redirected-with-o-but-no-output-will-be-gen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!