Don't override a package if all versions are deprecated#8997
Don't override a package if all versions are deprecated#8997amesgen wants to merge 1 commit intohaskell:masterfrom
Conversation
|
Thanks @amesgen ! I think this is a good chance to add some tests for active-repositories 🙂 you can follow along other tests in test-suite and ask here if something is not clear. Looking at the implementation. Is there any chance this can be implemented purely in IndexUtils? If the already exported merge and override functions are not enough, maybe PackageIndex can export an mergeWith function? |
Will try to take a stab 👍
The already existing
I don't have a preference, happy to go with any of these (or alternative) ways. |
|
I had a look at the code. The problem is that we merge "by-index" not "by-package". This wasn't clear to me. So what if we pre-process But now I am worried about the comment at the end of the function: cabal/cabal-install/src/Distribution/Client/IndexUtils.hs Lines 399 to 407 in a191f0a It seems as deprecating a package version in a repo will deprecate it in any other repo anyway. It's really unclear what the semantic should be here. When overriding, it would be natural to assume that packages "bring along" their preferences (so if pkg-a comes from repo-1, pkg-a prefs will be exactly the ones specified by repo-1). But what about merging? I guess it can only make sense if the preferences are a conjunction of |
Right now, deprecating a version will just tell the solver to try to find a plan that does not include it, but if it can not do that, deprecated versions can still end up in the build plan. Your suggestion would mean that deprecated versions vanish entirely, which I am not necessarily opposed to (also see #8863), but it might be out-of-scope for this particular PR (but OTOH, your suggestion would solve #8502 as a side effect, superseding this PR). |
You are right. I am clearly confused about how this works :-/ I'll familiarise myself with the code ... |
Consider
active-repositories:
, repo-a
, repo-b:override
and a package mypkg of which all versions in repo-b are deprecated (i.e. none is
preferred).
Before this patch, the solver would ignore all versions of mypkg in repo-a. After
this patch, it considers versions of mypkg in both repo-a and repo-b.
See haskell#8502 for motivation
a3020cf to
7d06a1d
Compare
|
Hello! Is there a way to move this PR forward? Can we help? |
One thing would be to turn the test scenario described in the PR description into a proper test in Cabal; I sadly don't think I currently have the motivation to do that myself. Last time I had a look, there were no tests involving the |
|
When the added |
Closes #8502, specifically by implementing #8502 (comment).
TODO:
:override-nondeprecated) rather than to change an existing one?I don't see any existing tests for the
active-repositoriesfunctionality; hence, here is how I tested these changes with a custom repo:This repo contains a single package, namely
tagged-0.8.6.1, which is marked as deprecated. https://github.com/amesgen/cabal-repo-override-example now contains a Cabal project withNow, with e.g. GHC 9.2.8, running
cabal updateandcabal buildwill result in the following version oftaggedbeing used:cabal-3.10.1.0:tagged-0.8.6.1. This is because only packages fromcabal-repo-override-exampleare considered.cabalbuilt from this PR:tagged-0.8.7, the (currently) newest version on Hackage, as now also versions from Hackage are considered.Also, to check that
:overridestill works when not all versions are deprecated, change theindex-stateofcabal-repo-override-exampleto2023-06-02T18:10:14Zwheretagged-0.8.6.1was not yet deprecated, and observe that also with thecabalfrom this PR, it is then chosen bycabal build.Will write a changelog entry and update the docs if the implementation approach looks okay.
Bonus points for added automated tests!