commercialhaskell / commercialhaskell/stack

Incorrect caching breaks the build: Change in indirect dependency breaks the build

Open
#5,507 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
4.1k
Forks
850
Avg merge
10h 37m
Merged PRs (30d)
4

Description

### General summary/comments (optional)

Change of dependency that is used directly and indirectly, and contains foreign binding to `libpq` in `extra-deps`
will cause failed build. Removing `.stack` and `stack-work` will fix the build.

### Steps to reproduce

For example:

1. Clone the project with one version of indirect dependency: `git clone https://gitlab.com/camlcase-dev/caldera.git`
2. Checkout commit before dependency update and build: `git checkout -b before-dependency-update ed0803f5c5726ee3b049e14ab94de3855961afd4`.
3. Apply dependency change: `git checkout -b after-dependency update f1eab185c6caa880ff69a299a547e80acf37abab`
Critical fragment is update of `stack.yaml`:
```
$ git show f1eab stack.yaml
--- a/stack.yaml
+++ b/stack.yaml
@@ -6,6 +6,8 @@ packages:
extra-deps:
- git: https://gitlab.com/camlcase-dev/servant-tezos-client.git
commit: c1a28f708e2f762207551dd2b3d53a08fbdf6741
+- git: https://github.com/mgajda/postgresql-simple
+ commit: 54dea885d295021f58811cb7a487120b99e4c3e2
```
4. Build with `stack build`.

### Expected

`stack` rebuilds successfully with new dependency.

### Actual

```[49 of 50] Compiling Paths_caldera
Preprocessing executable 'caldera-server' for caldera-0.17.0.0..
Building executable 'caldera-server' for caldera-0.17.0.0..
[2 of 2] Compiling Paths_caldera
Linking .stack-work/dist/x86_64-linux/Cabal-3.0.1.0/build/caldera-server/caldera-server ...
/home/james/.stack/snapshots/x86_64-linux/394c9f983d3ea6376867a939750f7d47fe29dce5b3111d6fde13dd6e886c32c8/8.8.4/lib/x86_64-linux-ghc-8.8.4/beam-postgres-0.5.0.0-9xYo9B4XMDfBDtQfN8zAFk/libHSbeam-postgres-0.5.0.0-9xYo9B4XMDfBDtQfN8zAFk.a(Syntax.o)(.text+0x3e6c6): error: undefined reference to 'postgresqlzmsimplezm0zi6zi4zm3nSyJycmVDX1jTUsQ3MQ6X_DatabaseziPostgreSQLziSimpleziTimeziInternalziPrinter_nominalDiffTime1_info'
/home/james/.stack/snapshots/x86_64-linux/394c9f983d3ea6376867a939750f7d47fe29dce5b3111d6fde13dd6e886c32c8/8.8.4/lib/x86_64-linux-ghc-8.8.4/beam-postgres-0.5.0.0-9xYo9B4XMDfBDtQfN8zAFk/libHSbeam-postgres-0.5.0.0-9xYo9B4XMDfBDtQfN8zAFk.a(Types.o):function beamzmpostgreszm0zi5zi0zi0zm9xYo9B4XMDfBDtQfN8zzAFk_DatabaseziBeamziPostgresziTypes_zdfFromBackendRowPostgresText3_info: error: undefined reference to 'postgresqlzmsimplezm0zi6zi4zm3nSyJycmVDX1jTUsQ3MQ6X_DatabaseziPostgreSQLziSimpleziFromField_zdfFromFieldTextzuzdcfromField1_closure'
/home/james/.stack/snapshots/x86_64-linux/394c9f983d3ea6376867a939750f7d47fe29dce5b3111d6fde13dd6e886c32c8/8.8.4/lib/x86_64-linux-ghc-8.8.4/beam-postgres-0.5.0.0-9xYo9B4XMDfBDtQfN8zAFk/libHSbeam-postgres-0.5.0.0-9xYo9B4XMDfBDtQfN8zAFk.a(Types.o):function beamzmpostgreszm0zi5zi0zi0zm9xYo9B4XMDfBDtQfN8zzAFk_DatabaseziBeamziPostgresziTypes_zdfFromBackendRowPostgresValue1_info: error: undefined reference to 'postgresqlzmsimplezm0zi6zi4zm3nSyJycmVDX1jTUsQ3MQ6X_DatabaseziPostgreSQLziSimpleziFromField_zdfFromFieldValuezuzdcfromField_closure'
/home/james/.stack/snapshots/x86_64-linux/394c9f983d3ea6376867a939750f7d47fe29dce5b3111d6fde13dd6e886c32c8/8.8.4/lib/x86_64-linux-ghc-8.8.4/beam-postgres-0.5.0.0-9xYo9B4XMDfBDtQfN8zAFk/libHSbeam-postgres-0.5.0.0-9xYo9B4XMDfBDtQfN8zAFk.a(Types.o)(.text+0x6f27): error: undefined reference to 'postgresqlzmsimplezm0zi6zi4zm3nSyJycmVDX1jTUsQ3MQ6X_DatabaseziPostgreSQLziSimpleziFromField_zdfFromFieldEither1_info'
/home/james/.stack/snapshots/x86_64-linux/394c9f983d3ea6376867a939750f7d47fe29dce5b3111d6fde13dd6e886c32c8/8.8.4/lib/x86_64-linux-ghc-8.8.4/beam-postgres-0.5.0.0-9xYo9B4XMDfBDtQfN8zAFk/libHSbeam-postgres-0.5.0.0-9xYo9B4XMDfBDtQfN8zAFk.a(Types.o)(.data+0x11b8): error: undefined reference to 'postgresqlzmsimplezm0zi6zi4zm3nSyJycmVDX1jTUsQ3MQ6X_DatabaseziPostgreSQLziSimpleziFromField_zdfFromFieldTextzuzdcfromField1_closure'
/home/james/.stack/snapshots/x86_64-linux/394c9f983d3ea6376867a939750f7d47fe29dce5b3111d6fde13dd6e886c32c8/8.8.4/lib/x86_64-linux-ghc-8.8.4/beam-postgres-0.5.0.0-9xYo9B4XMDfBDtQfN8zAFk/libHSbeam-postgres-0.5.0.0-9xYo9B4XMDfBDtQfN8zAFk.a(Types.o)(.data+0x1298): error: undefined reference to 'postgresqlzmsimplezm0zi6zi4zm3nSyJycmVDX1jTUsQ3MQ6X_DatabaseziPostgreSQLziSimpleziFromField_zdfFromFieldValuezuzdcfromField_closure'
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
Completed 181 action(s).
```

If you suspect that a stack command misbehaved, please include the output of that command in `--verbose` mode.
If the output is larger than a page please paste the output in a [Gist](https://gist.github.com/).

```
stack build --verbose
```
[Verbose output is here](https://gist.github.com/mgajda/7d96e856bfb27afb65c3afc9d30031bc)

### Stack version

```
$ stack --version
Version 2.5.1, Git revision d6ab861544918185236cf826cb2028abb266d6d5 x86_64 hpack-0.33.0
```

### Method of installation

* Official binary, downloaded from get.stackage.org.

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.