Skip to content

How to freeze #9984

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

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
Draft

How to freeze #9984

wants to merge 20 commits into from

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)

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

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

Co-Authored-By: Langston Barrett <[email protected]>
all dependencies but once it has decided, those versions are immediately
pinned.

This is "thaw and freeze" workflow is the simplest way to work with a

Choose a reason for hiding this comment

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

Suggested change
This is "thaw and freeze" workflow is the simplest way to work with a
This "thaw and freeze" workflow is the simplest way to work with a

- To pin the version of a new dependency

The steps of this workflow are add the new dependency and freeze. The solver
is free to chose its version for the new dependency while retaining the

Choose a reason for hiding this comment

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

Suggested change
is free to chose its version for the new dependency while retaining the
is free to choose a version for the new dependency while retaining the

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