Skip to content

Provide a way to let cabal freeze freeze dependencies, only #7944

Open

Description

@robx

Describe the bug
I'm not sure whether there's a bug, but the behaviour I see is, e.g.:

  • create x.cabal with a flag definition:
flag debug
  description: Enable debug support
  default: False
  • run cabal freeze; cabal.project.freeze now includes x -debug
  • in cabal.project.local, set flags: +debug

Now cabal build fails:

[__1] rejecting: x:-debug (constraint from config file, command line flag, or
user target requires opposite flag selection)
[__1] rejecting: x:+debug (constraint from project config
/private/tmp/x/cabal.project.freeze requires opposite flag selection)

I can work around this by following up cabal freeze with removing the flag constraint on x, but that's painful. Some thoughts:

  • should cabal freeze constrain local packages at all?
  • cabal freeze help lists the flag --dependencies-only, which doesn't seem to do anything; maybe it could be made to not set local package flags?

Tested with cabal-install 3.6.2.0 on macOS.

Activity

  1. gbaz commented on Feb 1, 2022

    @gbaz
    Collaborator

    cabal freeze is absolutely intended to constrain local packages. The desire is for a reproducible build, and the flag selection is absolutely part of reproducing the build.

    Note that the debug flag could change the deps required, including their versions, in which case if you did a freeze with deps calculated with the flag on, and tried to run it with the flag off, the constraints might not even be satisfiable!

  2. robx commented on Feb 1, 2022

    @robx
    CollaboratorAuthor

    So what's the intended usage story then for packages with flags?

  3. gbaz commented on Feb 1, 2022

    @gbaz
    Collaborator

    I mean, the intended usage is it records the flags and the deps both, and that freezes a reproducible configuration. If you want to have a reproducible configuration with a different set of flags, you use a different freeze file for that. Or, in this case, if you know your flag has no effect on dependencies, then, sure, delete the flag from the generated freeze file if you like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions