haskell / haskell/cabal

Flags in local config do not override flags in freeze file

Open
#10,439 1 comment 0 reactions 0 assignees View on GitHub
needs triage type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**

In my project, I have a project freeze file that has flag settings for local packages set to `-some-flag`. I expect to be able to override this flag in the local project config, following the precedence order given in the documentation: https://cabal.readthedocs.io/en/stable/cabal-project-description-file.html#project-description-cabal-project-file .

But when trying to build, I get a resolution conflict instead.

**To Reproduce**
Steps to reproduce the behavior:

```
$ cat cabal-freeze-bug.cabal
cabal-version: 3.0
name: cabal-freeze-bug
version: 0.1.0.0
synopsis: n
-- description:
license: BSD-2-Clause
license-file: LICENSE
author: Björn Gohla
maintainer: bjorn.gohla@scrive.com
-- copyright:
category: Testing
build-type: Simple
extra-doc-files: CHANGELOG.md
-- extra-source-files:

flag some-flag
description: a flag that does nothing
default: True

common warnings
ghc-options: -Wall

executable cabal-freeze-bug
import: warnings
main-is: Main.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: Haskell2010
$ cat cabal.project.freeze
active-repositories: hackage.haskell.org:merge
constraints: any.base ==4.18.2.1,
cabal-freeze-bug +some-flag,
any.ghc-bignum ==1.3,
any.ghc-prim ==0.10.0,
any.rts ==1.0.2
index-state: hackage.haskell.org 2024-06-14T08:17:16Z
$ cat cabal.project.local
ignore-project: False
flags: -some-flag
$ cabal build
Resolving dependencies...
Error: cabal: Could not resolve dependencies:
[__0] trying: cabal-freeze-bug-0.1.0.0 (user goal)
[__1] rejecting: cabal-freeze-bug:+some-flag (constraint from config file,
command line flag, or user target requires opposite flag selection)
[__1] rejecting: cabal-freeze-bug:-some-flag (constraint from project config
/home/bgohla/src/scratch/cabal-freeze-bug/cabal.project.freeze requires
opposite flag selection)
[__1] fail (backjumping, conflict set: cabal-freeze-bug,
cabal-freeze-bug:some-flag)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: cabal-freeze-bug:some-flag,
cabal-freeze-bug
```

**Expected behavior**

I expect the flags specified in the local project config to override the flags in the freeze file.

**System information**
```
$ cabal --version
cabal-install version 3.10.3.0
compiled using version 3.10.3.0 of the Cabal library
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.6.5
$ uname -smprv
Linux 6.8.9 #1-NixOS SMP PREEMPT_DYNAMIC Thu May 2 14:35:35 UTC 2024 x86_64 unknown
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the conflict using the shown cabal-freeze-bug.cabal, cabal.project.freeze, and cabal.project.local files, then run cabal build with the reported Cabal and GHC versions. Trace how flags from the local config and freeze file are combined, and consider the issue done when the documented precedence is honored without a resolution conflict.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.