Skip to content

Honour --with-ghc-pkg and ghc-pkg-location again (fixes #12694) - #12695

Closed
simonmar wants to merge 1 commit into
haskell:masterfrom
simonmar:with-ghc-pkg
Closed

simonmar wants to merge 1 commit into
haskell:masterfrom
simonmar:with-ghc-pkg

Conversation

@simonmar

@simonmar simonmar commented Dec 3, 2026

Copy link
Copy Markdown
Member

Since 3.18, cabal-install ran the ghc-pkg that it found next to ghc, not the one that the user gave with --with-ghc-pkg or with ghc-pkg-location in the project file.

configureCompiler drops the unconfigured programs of the cached ProgramDb before configCompilerProgDb configures ghc-pkg, and the user's location for a program is kept on its unconfigured entry. The user's locations are applied again afterwards, but that has no effect on a program that is already configured. So the user's ghc-pkg location is now passed to configCompilerProgDb, as --with-hc-pkg is. --with-hc-pkg still takes precedence over it.

Template B: This PR does not modify behaviour or interface

E.g. the PR only touches documentation or tests, does refactorings, etc.

Include the following checklist in your PR:

  • 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).

Since 3.18, cabal-install ran the ghc-pkg that it found next to ghc,
not the one that the user gave with --with-ghc-pkg or with
ghc-pkg-location in the project file.

configureCompiler drops the unconfigured programs of the cached
ProgramDb before configCompilerProgDb configures ghc-pkg, and the
user's location for a program is kept on its unconfigured entry. The
user's locations are applied again afterwards, but that has no effect
on a program that is already configured. So the user's ghc-pkg location
is now passed to configCompilerProgDb, as --with-hc-pkg is.
--with-hc-pkg still takes precedence over it.

The WithGhcPkg test now checks --with-ghc-pkg and ghc-pkg-location as
well as --with-hc-pkg.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ffaf1

ffaf1 commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Template B: This PR does not modify behaviour or interface

This PR definitely modifies behaviour.

@simonmar

simonmar commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

This PR definitely modifies behaviour.

Well, it's fixing a regression, I don't know whether that should be considered a behaviour change but there's a changelog entry anyway.

hc
(clearUnconfiguredPrograms hcProgDb)
hcPkg
(hcPkg <|> lookup "ghc-pkg" userProgramPaths)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm sorry, but I really don't like these band-aid fixes that tack on ad-hoc logic. I'm already finding it very hard to bring some sense to the Cabal codebase; I don't want a proliferation of LLM-assisted PRs entangling the logic further.

As written, this change means that the rule "--with-hc-pkg overrides the ghc-pkg location" lives in two places: in cabal-install (here) and in Cabal's configureCompilerPrograms. The fix should be to change configCompilerProgDb to avoid losing the user-specified path of ghc-pkg, not paper over it after the fact.

@sheaf

sheaf commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

If you can wait a bit, I'm working on approach that will fix this in #12556. I haven't pushed yet, as the further I dig the more issues I find need to be resolved for a coherent solution.

@simonmar

simonmar commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

Cool, I'll close this one then.

@simonmar simonmar closed this Dec 3, 2026
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.

3 participants