Skip to content

Conversation

@philderbeast
Copy link
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).

``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.

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

@philderbeast philderbeast force-pushed the docs/freeze-brrgh branch 3 times, most recently from c99ce5a to b7b8296 Compare February 9, 2025 21:36
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.

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

@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
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 +242
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

@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.

dependency versions are selected in each environment. This can be done
with the ``freeze`` command:

``cabal freeze`` writes out a **freeze file** which records all of

Choose a reason for hiding this comment

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

I like that this section used to introduce the phrase "freeze file" for discussing such files regardless of their particular file name. I've found this vocabulary helpful when discussing the management of such files. I would suggest keeping it around.

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.

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?

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.

@philderbeast philderbeast force-pushed the docs/freeze-brrgh branch 2 times, most recently from da92c38 to 652f854 Compare April 27, 2025 09:58
philderbeast and others added 2 commits January 27, 2026 10:50
Co-authored-by: Langston Barrett <[email protected]>
Co-authored-by: Langston Barrett <[email protected]>
package that is a dependency of the project, then the solver will not be
able to find a different version for any of them, the ``.freeze`` file
cannot change and, at that point when every dependency is frozen, ``cabal
freeze`` becomes an idempotent operation.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wonder if it is possible to generate different version constraints even when all dependencies are frozen? Could this happen if there's a revision made to hackage that effectively excludes the pinned version from the solver. Could local constraints do the same?

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.

4 participants