Skip to content

Conditional sections in cabal.project can be silently ignored depending on cache state #8699

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
Bodigrim opened this issue Jan 25, 2023 · 2 comments
Labels
re: conditional About conditional declarations in cabal files(`if`) re: project-file Concerning cabal.project files status: consider closing type: bug

Comments

@Bodigrim
Copy link
Collaborator

On two separate occasions I've hit an issue with conditionals in cabal.project, which I nevertheless cannot reliably reproduce after cabal clean. Thus this ticket is likely for future reference only, maybe someone will be more lucky / persistent.

The issue I witnessed is that

if(impl(ghc >= 9.6))

section in cabal.project was ignored by cabal build -w ghc-9.6. The necessary (but not sufficient) preconditions seem to be that ghc in PATH is ghc-9.4 and there was a successful cabal build before (implicitly with GHC 9.4).

Cf. #7783 and #8358.

@Bodigrim
Copy link
Collaborator Author

Bodigrim commented Feb 1, 2023

Here is a reproducer. Save

cabal-version: 3.4
name: conditionals-in-project
version: 0

library
  build-depends:
    base < 4.17

as conditionals-in-project.cabal, and

packages: .

if(impl(ghc >= 9.4))
  allow-newer: conditionals-in-project:base

as cabal.project.

Now both cabal clean && cabal build -w ghc-9.2 and cabal clean && cabal build -w ghc-9.4 succeed, but cabal clean && cabal build -w ghc-9.2 && cabal build -w ghc-9.4 fails with Could not resolve dependencies, because if(impl(ghc >= 9.4)) section is ignored.

$ cabal clean && cabal build -w ghc-9.2 && cabal build -w ghc-9.4
Resolving dependencies...
Build profile: -w ghc-9.2.5 -O1
In order, the following will be built (use -v for more details):
 - conditionals-in-project-0 (lib) (first run)
Configuring library for conditionals-in-project-0..
Preprocessing library for conditionals-in-project-0..
Building library for conditionals-in-project-0..
Resolving dependencies...
Error: cabal: Could not resolve dependencies:
[__0] trying: conditionals-in-project-0 (user goal)
[__1] next goal: base (dependency of conditionals-in-project)
[__1] rejecting: base-4.17.0.0/installed-4.17.0.0 (conflict:
conditionals-in-project => base<4.17)
[__1] skipping: base-4.17.0.0 (has the same characteristics that caused the
previous version to fail: excluded by constraint '<4.17' from
'conditionals-in-project')
[__1] rejecting: base-4.16.4.0, base-4.16.3.0, base-4.16.2.0, base-4.16.1.0,
base-4.16.0.0, base-4.15.1.0, base-4.15.0.0, base-4.14.3.0, base-4.14.2.0,
base-4.14.1.0, base-4.14.0.0, base-4.13.0.0, base-4.12.0.0, base-4.11.1.0,
base-4.11.0.0, base-4.10.1.0, base-4.10.0.0, base-4.9.1.0, base-4.9.0.0,
base-4.8.2.0, base-4.8.1.0, base-4.8.0.0, base-4.7.0.2, base-4.7.0.1,
base-4.7.0.0, base-4.6.0.1, base-4.6.0.0, base-4.5.1.0, base-4.5.0.0,
base-4.4.1.0, base-4.4.0.0, base-4.3.1.0, base-4.3.0.0, base-4.2.0.2,
base-4.2.0.1, base-4.2.0.0, base-4.1.0.0, base-4.0.0.0, base-3.0.3.2,
base-3.0.3.1 (constraint from non-upgradeable package requires installed
instance)
[__1] fail (backjumping, conflict set: base, conditionals-in-project)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, conditionals-in-project

@Bodigrim Bodigrim changed the title Heisenbug with if(impl(ghc >= 9.6)) in cabal.project Conditional section in cabal.project can be silently ignored depending on cache state Feb 1, 2023
@Bodigrim Bodigrim changed the title Conditional section in cabal.project can be silently ignored depending on cache state Conditional sections in cabal.project can be silently ignored depending on cache state Feb 1, 2023
@Bodigrim Bodigrim added re: conditional About conditional declarations in cabal files(`if`) re: project-file Concerning cabal.project files labels Feb 17, 2023
@Mikolaj
Copy link
Member

Mikolaj commented Jun 17, 2023

#8819 say it resolves this issue. Could you verify and close it, if so?

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 status: consider closing type: bug
Projects
None yet
Development

No branches or pull requests

3 participants