Skip to content

active-repositories: Don't override fully-deprecated packages#11760

Open
erikd wants to merge 1 commit intohaskell:masterfrom
erikd:erikd/dont-override-if-all-deprecated
Open

active-repositories: Don't override fully-deprecated packages#11760
erikd wants to merge 1 commit intohaskell:masterfrom
erikd:erikd/dont-override-if-all-deprecated

Conversation

@erikd
Copy link
Copy Markdown
Member

@erikd erikd commented Apr 21, 2026

This PR takes over #8997 from the original author Alexander Esgen who unfortunately passed away late last year.

The PR includes tests and additions to the documentation.

When active-repositories includes a repo with :override, and that repo's preferred-versions marks all its versions of a package as deprecated, the index-combining step previously still applied full override semantics, hiding all versions of that package from earlier repos.

Fix by consulting preferred-versions when combining indexes: if lookupDependency finds no preferred version for a package in the override repo, fall back to merge semantics so earlier-repo versions remain visible.

Two changes:

  • PackageIndex: add overrideOrMerge, a per-package Override/Merge strategy
  • IndexUtils: add deprecationAwareStrategy, wired into getSourcePackagesAtIndexState

Fixes #8502

This code was originally authored by Alexander Esgen and sumbitted in a PR over 2 years ago. Erik manually rebased that code onto master and used Claude to add tests and do some very minor refactoring to Alexander's code to make it more testable.

Please read Github PR Conventions and then fill in one of these two templates.


Include the following checklist in your PR:

@erikd erikd force-pushed the erikd/dont-override-if-all-deprecated branch 3 times, most recently from 38c15e5 to c257e5a Compare April 21, 2026 05:28
@erikd erikd force-pushed the erikd/dont-override-if-all-deprecated branch from c257e5a to b5a6079 Compare April 21, 2026 06:04
@erikd
Copy link
Copy Markdown
Member Author

erikd commented Apr 21, 2026

Tagging @andreabedini because he had some comments on Alexanders original PR.

@Mikolaj In July last year you asked if Alexander's PR could be moved forward. As I stated at the top, I have taken this over after Alexander passed.

@Mikolaj
Copy link
Copy Markdown
Member

Mikolaj commented Apr 21, 2026

@Mikolaj In July last year you asked if Alexander's PR could be moved forward. As I stated at the top, I have taken this over after Alexander passed.

Oh, I didn't now about Alexander. I'm honoured to help carry onward his work. Let me also mark @geekosaur, who reviewed the original PR. @erikd, please don't forget to set the needs-review label as soon as you'd like to widen the pool of reviewers.

@Mikolaj
Copy link
Copy Markdown
Member

Mikolaj commented Apr 21, 2026

An initial technical question: does the test have the property that it fails without the PR and succeeds with it? I assume the tests from #11684 don't have this property and so they just check this PR doesn't break how active-repositories should work, right?

@erikd
Copy link
Copy Markdown
Member Author

erikd commented Apr 22, 2026

@Mikolaj If I back out some of the changes in cabal-install/src/Distribution/Client/IndexUtils.hs then 3 out of the 610 tests (running cabal test cabal-install:unit-tests) fail. They all passed before I backed out the changes.

Otherwise, yes, the tests in #11684 were just to test the "active-repositories" features so that these changes did not break that functionality.

@Mikolaj
Copy link
Copy Markdown
Member

Mikolaj commented Apr 22, 2026

Good to know. Are the failing tests the newly added overrideOrMergeTests and/or deprecationAwareStrategyTests?

@erikd erikd force-pushed the erikd/dont-override-if-all-deprecated branch from b5a6079 to 02f4672 Compare April 23, 2026 03:05
@erikd
Copy link
Copy Markdown
Member Author

erikd commented Apr 23, 2026

Inspecting the failures more closely, they are a) intermittent and b) not related to the changes in this PR. For some reason a couple of tests in the UnitTests.Distribution.Client.UserConfig section fail intermittently with things like:

  UnitTests.Distribution.Client.UserConfig
    nullDiffOnCreate:                                                                        OK (0.02s)
    canDetectDifference:                                                                      FAIL
      Exception: /home/erikd/Git/Haskell/cabal/cabal-install/tests/fixtures/project-root/
         test-user-config.tmp: withFile: resource busy (file is locked)
      
      HasCallStack backtrace:
        ioException, called at libraries/ghc-internal/src/GHC/Internal/IO/FD.hs:331:17 in
          ghc-internal:GHC.Internal.IO.FD
      
      Use -p '/canDetectDifference/' to rerun this test only.

I did some further refactoring to expose addIndex so I could add unit tests specifically testing the Merge/Orverride/Skip logic.

There are still separate tests for addIndex and addStategy. Having separate (and cheap execution wise) tests is still worthwhile even though addIndex with an empty [Dependency] list behaves identically to applyStrategy for all three strategies.

Rebased against master as well.

@erikd erikd force-pushed the erikd/dont-override-if-all-deprecated branch from 02f4672 to 71dde16 Compare April 23, 2026 09:31
@philderbeast
Copy link
Copy Markdown
Collaborator

Inspecting the failures more closely, they are a) intermittent and b) not related to the changes in this PR.

Yes, they're not related. These failures are reported in #11686 with a fix in flight with #11759.

@erikd erikd force-pushed the erikd/dont-override-if-all-deprecated branch 2 times, most recently from e167474 to 689e85c Compare April 28, 2026 00:51
When active-repositories includes a repo with :override, and that repo's
preferred-versions marks all its versions of a package as deprecated, the
index-combining step previously still applied full override semantics,
hiding all versions of that package from earlier repos.

Fix by consulting preferred-versions when combining indexes: if
lookupDependency finds no preferred version for a package in the override
repo, fall back to merge semantics so earlier-repo versions remain visible.

 Two changes:
  - PackageIndex: add overrideOrMerge, a per-package Override/Merge strategy
  - IndexUtils: add deprecationAwareStrategy, wired into getSourcePackagesAtIndexState

Fixes haskell#8502

This code was originally authored by Alexander Esgen and sumbitted in a
PR over 2 years ago. Erik manually rebased that code onto master and used
Claude to add tests and do some very minor refactoring to Alexander's
code to make it more testable.

Co-Authored-By: Erik de Castro Lopo <erikd@mega-nerd.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@erikd erikd force-pushed the erikd/dont-override-if-all-deprecated branch from 689e85c to 2924f25 Compare April 30, 2026 05:23
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.

Name security in additional package repositories

5 participants