Skip to content

Building a specific target can cause bad state #2904

Closed
@spikefoo

Description

@spikefoo

(Using stack-1.3.2 on Arch Linux)

Steps to reproduce

Clone this sample project with two libraries: LibA, and LibB which depends on LibA.

$ ls
lib-a lib-b stack.yaml

Build with stack build, and run with stack exec lib-a-exe and stack exec lib-b-exe.

Next, change a function (named value) in LibA, and rebuild LibA only using stack build lib-a. Now lib-a-exe uses the updated function, but lib-b-exe still uses the old one, as expected.

Now try to rebuild LibB with stack build lib-b or stack build.

Expected

stack should update (relink?) LibB to use the new version of LibA.

Actual

stack never rebuilds LibB, causing it to forever use the old LibA.

This was suprising for me, because I thought stack build lib-a && stack build lib-b was equivalent to stack build. Instead, I found out it can result in a bad state where LibB is never rebuilt, forcing me to use one of these workarounds:

Workaround

After making a change in LibA and running stack build lib-a, either:

  • Change a source file in LibB, forcing a rebuild. Or:
  • Remove lib-b/.stack-work.

Alternatively, never build a specific target (e.g. stack build lib-a) in the first place. Always run stack build to build all targets.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions