Skip to content

How to freeze#9984

Draft
philderbeast wants to merge 41 commits intohaskell:masterfrom
cabalism:docs/freeze-brrgh
Draft

How to freeze#9984
philderbeast wants to merge 41 commits intohaskell:masterfrom
cabalism:docs/freeze-brrgh

Conversation

@philderbeast
Copy link
Copy Markdown
Collaborator

Follow on from the draft #8053, moving the new content to a "How to freeze" how-to guide.

  • Patches conform to the coding conventions.
  • Is this a PR that fixes CI? If so, it will need to be backported to older cabal release branches (ask maintainers for directions).

Comment thread doc/cabal-commands.rst Outdated
``cabal.project.freeze`` you are guaranteed that every future ``cabal`` call
will use the exact same set of dependencies, regardless of any updates (even
patches) that might get published for these dependencies in the meantime.
Therefore, we have effectively "frozen" the dependencies in place.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also mention that while cabal.project.freeze restricts specified dependency versions, it does NOT prevent from including future dependencies unless reject-unconstrained-dependencies=all is specified

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked and reject-unconstrained-dependencies=all is fairly lenient, #11468.

@philderbeast philderbeast force-pushed the docs/freeze-brrgh branch 3 times, most recently from c99ce5a to b7b8296 Compare February 9, 2025 21:36
Comment thread doc/how-to-freeze-versions.rst Outdated
Comment thread doc/how-to-freeze-versions.rst Outdated
Comment on lines +214 to +215
simplest and the most common. Finally, you will always want to commit the
changed ``cabal.project.freeze`` to version control.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you will always want to commit the changed cabal.project.freeze to version control.

I find this a bit misleading - I believe you would want to commit the changed cabal.project.freeze iff one was already committed.

cannot change and, at that point when every dependency is frozen, ``cabal
freeze`` becomes an idempotent operation.

Adding a dependency to one of the packages in a project without freezing harder
Copy link
Copy Markdown

@langston-barrett langston-barrett Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line doesn't make sense unless you read the previous section to know what "freeze harder" means. Some readers might land on this section by following a link to it directly. Perhaps be more explicit?

Suggested change
Adding a dependency to one of the packages in a project without freezing harder
Adding a dependency to one of the packages in a project without running ``cabal freeze`` again

or

Suggested change
Adding a dependency to one of the packages in a project without freezing harder
Adding a dependency to one of the packages in a project without regenerating the ``cabal.project.freeze`` file using one of the methods described above

(Perhaps with a link to the above section)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @langston-barrett. Even worse, I don't explain "freeze harder".

Comment on lines +229 to +233
leaves the newly added dependency susceptible to getting updated unexpectedly
when the solver can find a different version for it. Running ``cabal freeze``
will show this vulnerability to a human or an automated check that notices a new
version equality constraint in the ``.freeze`` file, a constraint for a package
that wasn't in the ``.freeze`` file before.
Copy link
Copy Markdown

@langston-barrett langston-barrett Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest rephrasing this paragraph along these lines

When adding a new dependency to a project that utilizes a freeze file, it is often desirable to regenerate the freeze file using one of the methods described above. This ensures that the freeze file contains a constraint for the new dependency.

Comment thread doc/cabal-commands.rst
Comment thread doc/cabal-commands.rst Outdated
Comment on lines +529 to +518
For end-user executables, it is recommended that you distribute the
``cabal.project.freeze`` file in your source repository so that all
users see a consistent set of dependencies. For libraries, this is not
recommended: users often need to build against different versions of
libraries than what you developed against.
``cabal.project.freeze`` is intended to be committed to the version control.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to see a lot more discussion about this recommendation. Firstly, as noted elsewhere, a cabal.project.freeze file pins a particular version of base, and hence GHC. What if my CI tests against multiple versions of GHC?

Also, why did this recommendation change as part of this PR? What was the rationale behind the previous recommendation (check it in for executables and not for libraries), and what has changed since it was written?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously the ecosystems and tools are quite different, but for reference, Cargo does unconditionally recommend checking in Cargo.lock files (similar to how this now recommends checking in cabal.project.freeze files). However, they have a much more thorough discussion of the considerations and consequences of doing so.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I don't think we should recommend putting cabal.project.freeze under Git. The previous recommendation was more balanced, although also not followed widely, precisely because it makes testing against multiple versions of GHC very annoying.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted. I intend to write a lot more around this in the guide.

Comment thread doc/how-to-freeze-versions.rst Outdated
@philderbeast philderbeast force-pushed the docs/freeze-brrgh branch 2 times, most recently from da92c38 to 652f854 Compare April 27, 2025 09:58
Comment thread doc/how-to-freeze-versions.rst Outdated
Comment thread doc/how-to-freeze-versions.rst Outdated
philderbeast and others added 29 commits April 15, 2026 13:59
Co-Authored-By: Langston Barrett <langston.barrett@gmail.com>
Co-authored-by: Langston Barrett <langston.barrett@gmail.com>
Co-authored-by: Langston Barrett <langston.barrett@gmail.com>
Co-authored-by: ˌbodʲɪˈɡrʲim <andrew.lelechenko@gmail.com>
- link to exe hpack-dhall-cabal
- Add project environment section
- Keep cabal freeze command simple
- Move details to freeze guide and link to guide
Co-authored-by: brandon s allbery kf8nh <allbery.b@gmail.com>
Co-authored-by: brandon s allbery kf8nh <allbery.b@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants