Skip to content

stack build [target] no longer works, builds all targets #3229

Closed

Description

@nh2

There is a regression in stack that stack build myexe no longer builds just the executable myexe, but all executables from the package.

Especially projects with many executables, and projects where linking takes a long time suffer from this (both are the case for IOHK's cardano-sl).

The reason according to @mgsloan:

I think this was the result of switching from using runhaskell Setup.hs install to copy + register - f71a515 .
copy fails if it can't find every executable, and there's no way in released cabal to tell it to only copy particular targets. There was a patch well before the most recent cabal release, but for some reason it is only available on master. So, with future cabal this may be fixable.

Activity

  1. snoyberg commented on Jun 27, 2017

    @snoyberg
    Contributor

    Let's finally set to rest the theory that it's the switch from install to copy/register (it's not):

    stack new foo
    cd foo
    stack exec --no-ghc-package-path -- runghc Setup.hs configure --user
    stack exec --no-ghc-package-path -- runghc Setup.hs build lib:foo
    stack exec --no-ghc-package-path -- runghc Setup.hs install
    

    Results in:

    Installing library in
    /Users/michael/.cabal/lib/x86_64-osx-ghc-8.0.2/foo-0.1.0.0-K7FRl2SdaSPJF1E2Gf1Eav
    Installing executable(s) in /Users/michael/.cabal/bin
    Warning: The directory /Users/michael/.cabal/bin is not in the system search
    path.
    dist/build/foo-exe/foo-exe: copyFile: does not exist (No such file or
    directory)
    
  2. snoyberg commented on Jun 27, 2017

    @snoyberg
    Contributor

    The problem: Cabal (the library) will fail and die if you call the copy command when some of the executables are unavailable.

    Original solution: oh well, user will get an error message, realize he/she has to call build once without arguments, and then can give components.

    Current solution: never tell build to only build a subset of components, since that can lead to copy failing.

    Proposed solution: before calling Cabal build, Stack should check if all executables are built. If they are, pass in components. Otherwise, give a logInfo that we're building all components once, and then future calls will build individual components.

  3. self-assigned this
    on Jun 28, 2017
  4. chrisdone commented on Jun 28, 2017

    @chrisdone
    Member

    Found the related commit: dc6313f

  5. snoyberg commented on Jul 13, 2017

    @snoyberg
    Contributor

    Merged to master, closing.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions