Assertion failed after changing the `version:` field in the middle of a `cabal build`
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
Maybe `cabal` should cache the contents of build configuration files (`.cabal` files, `cabal.project` etc) during a build so that changes to these files don't get cabal into inconsistent states.
The scenario:
1. clone https://github.com/agda/agda, checkout tag `v2.7.0.1`, and start `cabal build`
2. once GHC starts compiling the 400+ modules of the `Agda` library, while the build is still running (takes quite a while), change the `version` in `Agda.cabal` to e.g. `2.7.0`.
3. then after the build is finished, restart `cabal build`
4. observe the `Assertion failed`; cabal is in an inconsistent state
Here is a run (with version 2.8.0.1 -> 2.8.0)
```
$ cabal build
...
[437 of 437] Compiling Agda.Main ( src/full/Agda/Main.hs, /Users/abela/agda/dist-newstyle/build/aarch64-osx/ghc-9.10.1/Agda-2.8.0.1/build/Agda/Main.o, /Users/abela/agda/dist-newstyle/build/aarch64-osx/ghc-9.10.1/Agda-2.8.0.1/build/Agda/Main.dyn_o )
...
./Agda.cabal has been changed. Re-configuring with most recently used options.
If this fails, please run configure manually.
Configuring library for Agda-2.8.0...
Configuring executable 'agda' for Agda-2.8.0...
Preprocessing executable 'agda' for Agda-2.8.0...
Building executable 'agda' for Agda-2.8.0...
[1 of 1] Compiling Main ( src/main/Main.hs, /Users/abela/agda/dist-newstyle/build/aarch64-osx/ghc-9.10.1/Agda-2.8.0.1/x/agda/build/agda/agda-tmp/Main.o )
[2 of 2] Linking /Users/abela/agda/dist-newstyle/build/aarch64-osx/ghc-9.10.1/Agda-2.8.0.1/x/agda/build/agda/agda
...
$ cabal build ✔ │ 5m 19s │ 18:05:41
Resolving dependencies...
Build profile: -w ghc-9.10.1 -O1
In order, the following will be built (use -v for more details):
- Agda-2.8.0.1 (lib) (configuration changed)
- Agda-2.8.0.1 (exe:agda-mode) (configuration changed)
- Agda-2.8.0.1 (exe:agda) (configuration changed)
Configuring executable 'agda-mode' for Agda-2.8.0.1...
Configuring library for Agda-2.8.0.1...
Preprocessing executable 'agda-mode' for Agda-2.8.0.1...
Building executable 'agda-mode' for Agda-2.8.0.1...
Preprocessing library for Agda-2.8.0.1...
Building library for Agda-2.8.0.1...
...
[8 of 8] Linking /Users/abela/agda/dist-newstyle/build/aarch64-osx/ghc-9.10.1/Agda-2.8.0.1/x/agda-mode/build/agda-mode/agda-mode [Objects changed]
...
[152 of 437] Compiling Agda.Setup ( src/setup/Agda/Setup.hs, /Users/abela/agda/dist-newstyle/build/aarch64-osx/ghc-9.10.1/Agda-2.8.0.1/build/Agda/Setup.o, /Users/abela/agda/dist-newstyle/build/aarch64-osx/ghc-9.10.1/Agda-2.8.0.1/build/Agda/Setup.dyn_o ) [src/data/latex/agda.sty changed]
...
Configuring executable 'agda' for Agda-2.8.0.1...
Assertion failed
CallStack (from HasCallStack):
assert, called at src/Distribution/Simple/PackageIndex.hs:210:30 in Cabal-3.12.1.0-inplace:Distribution.Simple.PackageIndex
mkPackageIndex, called at src/Distribution/Simple/PackageIndex.hs:225:17 in Cabal-3.12.1.0-inplace:Distribution.Simple.PackageIndex
Error: [Cabal-7125]
Failed to build exe:agda from Agda-2.8.0.1. The failure occurred during the configure step.
```
Contributor guide
Assessment
This issue has not been assessed yet.