commercialhaskell / commercialhaskell/stack
Executable not rebuilt when a library is used by more than one executable
- Dominant language
- Haskell
- Stars
- 4.1k
- Forks
- 850
- Avg merge
- 10h 37m
- Merged PRs (30d)
- 4
Description
### General summary/comments (optional)
With a `stack.yaml` containing more than one executable, Stack can lose track of what needs to be rebuilt when libraries used by multiple executables change.
### Steps to reproduce
Repo at https://github.com/mtolly/rebuild-bug
Contains a library, and two programs (in separate `.cabal`) using it. After an initial build, modifying the library code and rebuilding only one of the executables leads to a state where the other executable is out of date, but Stack does not rebuild it unless `--force-dirty` is applied.
```
$ stack build
(builds both programs)
$ stack exec exe1
Executable 1: 123
$ stack exec exe2
Executable 2: 123
$ (edit lib/MyLib.hs from 123 to 456)
$ stack build exe1
(rebuilds lib and exe1)
$ stack exec exe1
Executable 1: 456
$ stack build
(nothing happens, exe2 should rebuild but does not)
$ stack exec exe2
Executable 2: 123
$ stack build --force-dirty
(rebuilds exe2)
$ stack exec exe2
Executable 2: 456
```
### Expected
`exe2` should be rebuilt with either `stack build` or `stack build exe2`.
### Actual
Neither command rebuilds `exe2` until another change is made, or `--force-dirty` is added.
### Stack version
```
$ stack --version
Version 2.2.0, Git revision a9f274abf04ac6240e0859cb625c36a6b8f9034e PRE-RELEASE x86_64 hpack-0.32.0
```
I also observed the behavior on the current release version (2.1.3).
### Method of installation
First the curl script on haskellstack.org, then `stack upgrade --git`.
Contributor guide
Assessment
This issue has not been assessed yet.