-
Notifications
You must be signed in to change notification settings - Fork 703
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
Add a --lock
flag to cabal freeze
to promote a freeze file to a lock file
#10785
base: master
Are you sure you want to change the base?
Conversation
e2bd875
to
e6ac5aa
Compare
I think the changelog and docs should disclose the connection between the new flag and the old one. |
5f10ce4
to
6b8995f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks neat, thank you for the contribution!
Why is the flag named |
I think the term "lock file" or "lock" is very widely used for the purpose of this PR in other languages (js with Yarn and rust's Cargo come to mind). It is however true that what it really does is rejecting any unconstrained dependencies. I this it is a question of familiarity vs precision. |
I think it's not a good thing to invent aliases. It will make searching documentation harder and understanding the relation between flags. |
It's not an alias: while --lock affects behavior of cabal freeze (makes it generate a slightly different freeze file than before), --reject-unconstrained-dependencies affects behavior of v2-builds making them reject plans with dependencies not converted by provided constraints. These are absolutely different things, so, I don't see why they should be named the same. |
Maybe I'm reading the proposal wrong:
|
As @ulysses4ever mentioned,
Calling What we want to do here instead is:
This is what cabal freeze && cabal configure --reject-unconstrained-dependencies=all although we want the Right now, in documentation, I wrote that:
What if I wrote this instead?
|
Yes, my intuition was that And now I realize the interface is confusing:
I think it might be worthwhile to have some type of interface that allows to add "arbitrary" (but cabal sanity checked) stanzas to the freeze file. E.g. |
I see what you mean. A freeze file is a valid cabal project file (a fact I didn't know until making this PR!), so technically any command accepted by The freeze file write out project configuration according to this particular line of code, which as you can see only relays a few things (constraints, index state, active repos). This PR adds another project configuration value to pass to the config. I still think |
What are the semantics of a "lock file" and that of a "freeze file"? Can we describe that in an abstract sense while ignoring the implementation details of cabal and all its switches? From the docs, it seems a "freeze file" is:
Now, a lock file is: ??? I'm worried about the usability. How would a new user understand If this is just for power users, I'd much rather prefer an option to add arbitrary stanzas. If we have an idea of what locking means and maybe it's more than just adding one line to the freeze file, could it be its own subcommand even? |
I would summarize it as:
I initially assumed that Should We can get 95% of the way to lockfiles with the PR here. Alternatively, we could change this PR to be a documentation change, specifying that a freeze file isn't exhaustive, and pointing users to the |
@Martinsos started and I'm continuing to write up a guide to freezing with #9984. If freezing and locking are different behaviours (I'm not sure) then perhaps they should be separate commands and have separate file extensions for their output, |
I'd always assumed that freeze files still allowing unconstrained dependencies was an oversight. Perhaps it's worth reaching out to the community, e.g. via a Discourse thread, to see whether anyone actually wants the current behaviour. And if not, then rather than adding any new flags or commands, just fix the existing |
Now that I think about it, if I don't depend on text, then run cabal freeze --lock, add My suspicion is that it won't fail because text is constrained (although not in the freeze file) defeating the purpose of this PR, no? I.e. will the reject-unconstrained-dependencies complain if the dependency is not constrained in the freeze file but constrained in the cabal file albeit very loosely constrained (even with >0)? |
Ahh damn, I just tested it and you're right. This means that the locking mechanism must go beyond re-using As @georgefst mentions, I was surprised by the |
Since the changes in this PR are clearly not enough to have the behavior I'm looking for, I suggest moving the discussion over on the original issue (#10784 ) until an appropriate design can be determined |
This pull request adds a
--lock
flag tocabal freeze
, promoting a freeze file to a lock file.Fixes #10784 .
QA Notes
Calling
cabal freeze --lock
should produce a freeze file, with one added line compared tocabal freeze
:Checklist
significance: significant
in the changelog file.