Skip to content

Caching issue with conditionals in project files #8772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wz1000 opened this issue Feb 16, 2023 · 2 comments · Fixed by #8819
Closed

Caching issue with conditionals in project files #8772

wz1000 opened this issue Feb 16, 2023 · 2 comments · Fixed by #8819
Labels
re: conditional About conditional declarations in cabal files(`if`) re: project-file Concerning cabal.project files type: bug

Comments

@wz1000
Copy link
Contributor

wz1000 commented Feb 16, 2023

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
@Mikolaj
Copy link
Member

Mikolaj commented Feb 16, 2023

The reported says that this also reproduces internal-second-prerelease-of-3.10.

@Mikolaj Mikolaj added type: bug re: conditional About conditional declarations in cabal files(`if`) re: project-file Concerning cabal.project files labels Feb 16, 2023
@Bodigrim
Copy link
Collaborator

Duplicate of #8699, I suppose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
re: conditional About conditional declarations in cabal files(`if`) re: project-file Concerning cabal.project files type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants