-
Notifications
You must be signed in to change notification settings - Fork 697
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
Override imported package version equalities #9510
base: master
Are you sure you want to change the base?
Override imported package version equalities #9510
Conversation
00a5b5f
to
4332c81
Compare
I have local tests that I used that reference two versions of
When I add these tests to
|
You should create a folder which contains package tarballs and use |
I'm glad you're working on this, but I think this by-depth design is probably overcomplicated? Wouldn't it be simpler (for users as well as implementers) to just have later constraints override earlier constraints? |
I'm not aware of any other configuration we have that is order dependent so (before working on this) would have expected the following two projects to pick the same override .
|
We sort of have order dependence in that we accumulate information monoidally. It just so happens that the monoids we accumulate in are typically the list monad. But if there is any project setting which is itself order-dependent in the accumulated list, then that will be observable. In general, I think order-dependence will be more intuitive to end-users than depth-dependence -- and there are other places, such as remote package repos, where an "overriding" semantics might be useful as well, so unless we want to annotate them all with depth, then it makes sense to start using order-dependence more, in a uniform way. |
Although a stack resolver is not an import, I did an experiment and there's no order dependence there. # stack.yaml
packages: ["."]
resolver: nightly-2023-12-07 # stack.stackage-vs-local.yaml
packages: ["."]
resolver: nightly-2023-12-07
extra-deps: [hashable-1.4.2.0] # stack.local-vs-stackage.yaml
packages: ["."]
extra-deps: [hashable-1.4.2.0]
resolver: nightly-2023-12-07
|
Thanks @mpickering, the way you suggested doing it is working. |
I want to be alerted if I have conflicting constraints at the same depth in the import tree. We shouldn't resolve the following (and keep reporting that solving "Could not resolve dependencies"): -- cabal.project
packages: .
constraints: hashable ==1.4.3.0
constraints: hashable ==1.4.2.0 |
f704226
to
e25b830
Compare
400f512
to
413fd3e
Compare
@Mikolaj I don't know why the |
That's what the github CI does occasionally for macos (congestion, probably). I've cancelled all and rerun all failed. I've bumped your role to "Maintain". Let me know if you can now rerun all from the button on the top-right of the CI runs screen. |
What about explicitly listed priority levels?
That would handle the basic case of overriding imported constraints (do we have any others?). If we were worried about more complex cases we could have annotated priority levels. That's kind of ugly, but it's what e.g. NixOS does to resolve setting conflicts. |
Thanks for the suggestion @michaelpj. I don't think we have to worry about overriding version equality constraints within the root project file. If there's a conflict (because we have two differing version equality constraints in the root project) hopefully the warning or error message is good enough to find the problem. I guess the concern here is that we won't be aware that we're overriding another constraint for the same package, one that is imported and not immediately visible from the root project? Would it help to report the overrides? |
I think my concern with the current design is that it ties the thing we want (constraint overriding) to a conceptually unrelated thing (whether the constraint comes from an import). For example
What should happen here? It entirely depends! Perhaps my company policy is that nobody is allowed to deviate from the package set, and so this should be an error. There is no particular reason to assume that "imported" should mean "overridable". My suggestion is to explicitly make statements about the thing we want to say: "this constraint overrides" (could also have "this constraint is overridable"). |
@michaelpj I don't see how preventing overrides could be enforced when an import can be downloaded locally and edited at will. |
413fd3e
to
081823c
Compare
Yes I can now see [Rerun all jobs] and [Rerun all failed jobs] buttons at the top right of the screen, thanks @Mikolaj. |
Thanks @gbaz, I agree. Trying out last wins (rather than shallowest wins) was slow going. The elements of the Note I'm guessing that
There's quite a few other places in the codebase where the order of elements may be reversed by fromListWith.
|
0d26e10
to
d5a5c35
Compare
I'm glad you are implementing the last version wins approach, but I have two concerns about how this code has evolved. I think that "last version wins" should not be implemented as affecting the solver. None of the code here should affect the solver. It should only affect how we collect and treat inputs to the solver. That sidesteps the whole issue of how the solver may or may not order constraints with Further, I think we should pick one approach and stick with it, rather than introducing a new flag that lets us switch between approaches. For testing purposes, its fine to have a flag so people can experiment. But what we merge and release should only be one way or the other, having explored the possibilities. |
bdd0ec1
to
f22279a
Compare
f22279a
to
7e6a207
Compare
- Add isVersionEqualityConstraint - Weed below shallowest import depth - Weed per package - Satisfy build of validate project
- Stackage has with-compiler: ghc-9.6.3 - allow-newer: hashable:* for tests - Avoid this diff because of conditionals in hashable package by comment out their conditional build-depends: + - base-orphans-0.9.1 (lib) (requires build) + - data-array-byte-0.1.0.1 (lib) (requires build) - hashable-1.4.2.0 (lib) (requires build) Accept that nightly builds with ghc-9.6.3
Rename to shallowConstraintsWin
- Log overriding constraints - Preserve the input order in outputs of later wins
7e6a207
to
5eecc63
Compare
Fixes #9511. Allows overriding package version equalities by giving priority to shallower constraints in the project import tree.