Skip to content

"stack build" succeeds even when an executable isn't generated #1846

Closed

Description

@mgsloan

Repro:

  1. Run stack build in the stack source tree

  2. edit src/main/Main.hs to instead have module Lol where

  3. Run stack install

Expected: Compilation error about there being no Main module

Actual:

There were multiple candidates for the Cabal entry "Test.hs" (/home/mgsloan/fpco/stack/Test.hs), picking /home/mgsloan/fpco/stack/src/test/Test.hs
stack-1.0.5: unregistering (local file changes: src/main/Main.hs)
stack-1.0.5: build
Preprocessing library stack-1.0.5...
In-place registering stack-1.0.5...
Preprocessing executable 'stack' for stack-1.0.5...
[2 of 2] Compiling Lol              ( src/main/Main.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.7.0/build/stack/stack-tmp/Lol.o )
Warning: output was redirected with -o, but no output will be generated
because there is no Main module.
There were multiple candidates for the Cabal entry "Test.hs" (/home/mgsloan/fpco/stack/Test.hs), picking /home/mgsloan/fpco/stack/src/test/Test.hs
stack-1.0.5: copy/register
Installing library in
/home/mgsloan/fpco/stack/.stack-work/install/x86_64-linux/lts-5.3/7.10.3/lib/x86_64-linux-ghc-7.10.3/stack-1.0.5-JOr3UWYYPpY49ufhnfW8sA
Installing executable(s) in
/home/mgsloan/fpco/stack/.stack-work/install/x86_64-linux/lts-5.3/7.10.3/bin
Registering stack-1.0.5...
Copying from /home/mgsloan/fpco/stack/.stack-work/install/x86_64-linux/lts-5.3/7.10.3/bin/stack to /home/mgsloan/.local/bin/stack

Copied executables to /home/mgsloan/.local/bin:
- stack

GHC warned us with Warning: output was redirected with -o, but no output will be generated because there is no Main module.. Rather unhelpful since this should really be a failure case.... EDIT: fixed in GHC 8 https://ghc.haskell.org/trac/ghc/ticket/10895

The old executable is getting copied. I'm not sure what to do about this, due to Setup.hs potentially directing it elsewhere. Ignoring that issue, though, for simple build types, we can delete the executable. This will cause cabal copy to fail, and yield a reasonable error.

Activity

  1. mgsloan commented on Feb 27, 2016

    @mgsloan
    ContributorAuthor

    Considering that this is fixed for GHC 8, my proposal is to have a special case for this:

    For GHC < 8 and simple build types, delete the executables before attempting to build them.

  2. added a commit that references this issue on Feb 29, 2016
  3. added this to the P2: Should milestone on Mar 5, 2016
  4. mgsloan commented on Mar 18, 2017

    @mgsloan
    ContributorAuthor

    GHC 8.0's fix for this seems sufficient, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions