commercialhaskell / commercialhaskell/stack

Packages shared between multiples projects aren't rebuilt

Open
#3,130 16 comments 3 reactions 0 assignees View on GitHub
type: bug
Dominant language
Haskell
Stars
4.1k
Forks
850
Avg merge
10h 37m
Merged PRs (30d)
4

Description

Sorry, this is a weird one :slightly_smiling_face:

Let's say you have 3 packages: `a`, `b`, and `c`. Both `a` and `b` depend on `c`. Furthermore, `a` and `b` are in separate Stack projects. Both specify `c` as a package in their project. This makes `c` a shared package between `a` and `b`.

If you build `a`, it will of course build `c`. Then make a change to `c` and build `b`, which will re-build `c`. Finally re-build `a`. I would expect that to re-build (or at least re-link) `c` but instead it does nothing. This means that `b` has the new `c` but `a` has the old `c`.

Here's exactly how to reproduce:

``` sh
mkdir c
echo '{ name: c, library: { dependencies: base, exposed-modules: C } }' > c/package.yaml
echo 'module C where c = 1' > c/C.hs

mkdir a
echo '{ resolver: lts-8.11, packages: [., ../c] }' > a/stack.yaml
echo '{ name: a, executables: { a: { dependencies: [base, c], main: a.hs } } }' > a/package.yaml
echo 'import C; main = print c' > a/a.hs

mkdir b
echo '{ resolver: lts-8.11, packages: [., ../c] }' > b/stack.yaml
echo '{ name: b, executables: { b: { dependencies: [base, c], main: b.hs } } }' > b/package.yaml
echo 'import C; main = print c' > b/b.hs

cd a
stack build
stack exec a
# => 1
cd ..

echo 'module C where c = 2' > c/C.hs

cd b
stack build
stack exec b
# => 2
cd ..

cd a
stack build
stack exec a
# => 1
# Should be `2`!
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.