Closed
Description
Describe the bug
There seems to be a cache invalidation issue when there are conditionals in cabal.project
files.
Changing the build configuration (eg ghc version) should invaldate the cache but it appears not to.
To Reproduce
Set up a project with 2 packages, one that builds with ghc version A, the other builds with ghc-version B.
Reproducing example here: https://github.com/wz1000/cabal-bug
$ tree
.
├── build92
│ ├── build92.cabal
│ ├── LICENSE
│ └── MyLib.hs
├── build94
│ ├── build94.cabal
│ ├── LICENSE
│ └── MyLib.hs
└── cabal.project
$ cat cabal.project
if impl(ghc >= 9.4)
packages: ./build94/
if impl(ghc < 9.4)
packages: ./build92/
$ diff -c1 build92/build92.cabal build94/build94.cabal
*** build92/build92.cabal 2023-02-16 17:29:15.377391010 +0530
--- build94/build94.cabal 2023-02-16 17:34:31.424605778 +0530
***************
*** 1,3 ****
cabal-version: 3.0
! name: build92
version: 0.1.0.0
--- 1,3 ----
cabal-version: 3.0
! name: build94
version: 0.1.0.0
***************
*** 17,19 ****
library
! if impl(ghc >= 9.4)
buildable: False
--- 17,19 ----
library
! if impl(ghc < 9.4)
buildable: False
$ cabal build -w ghc-9.2 all
Resolving dependencies...
Build profile: -w ghc-9.2.6 -O1
In order, the following will be built (use -v for more details):
- build92-0.1.0.0 (lib) (first run)
Warning: build92.cabal:20:5: Unknown field: import. Common stanza imports
should be at the top of the enclosing section
Configuring library for build92-0.1.0.0..
Preprocessing library for build92-0.1.0.0..
Building library for build92-0.1.0.0..
[1 of 1] Compiling MyLib ( MyLib.hs, /data/builds/cabal-bug/dist-newstyle/build/x86_64-linux/ghc-9.2.6/build92-0.1.0.0/build/MyLib.o, /data/builds/cabal-bug/dist-newstyle/build/x86_64-linux/ghc-9.2.6/build92-0.1.0.0/build/MyLib.dyn_o )
$ cabal build -w ghc-9.4 all
Resolving dependencies...
Error: cabal: Cannot build all the packages in the project because none of the
components are available to build: the library is marked as 'buildable: False'
$ rm -rf dist-newstyle
$ cabal build -w ghc-9.4 all
Resolving dependencies...
Build profile: -w ghc-9.4.4 -O1
In order, the following will be built (use -v for more details):
- build94-0.1.0.0 (lib) (first run)
Warning: build94.cabal:20:5: Unknown field: import. Common stanza imports
should be at the top of the enclosing section
Configuring library for build94-0.1.0.0..
Preprocessing library for build94-0.1.0.0..
Building library for build94-0.1.0.0..
[1 of 1] Compiling MyLib ( MyLib.hs, /data/builds/cabal-bug/dist-newstyle/build/x86_64-linux/ghc-9.4.4/build94-0.1.0.0/build/MyLib.o, /data/builds/cabal-bug/dist-newstyle/build/x86_64-linux/ghc-9.4.4/build94-0.1.0.0/build/MyLib.dyn_o )
Expected behavior
The build -w ghc 9.4
should succeed without having to delete dist-newstyle
System information
- Operating system: Linux
cabal
,ghc
versions: cabal-install 3.8.1.0