Skip to content

Document additional project config files are read from the root only#11976

Open
ninioArtillero wants to merge 1 commit into
haskell:masterfrom
ninioArtillero:root-configs
Open

Document additional project config files are read from the root only#11976
ninioArtillero wants to merge 1 commit into
haskell:masterfrom
ninioArtillero:root-configs

Conversation

@ninioArtillero

@ninioArtillero ninioArtillero commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

This documentation addition reflects my experiments with 3.16.1.0, after struggling with a behavior I did not expected:
a cabal.project.local specifying local packages I was developing a subproject against stopped being read after a cabal.project file was added to the top level project root, thus reverting to the store version of the package specified in the subproject cabal file, and resulting in a wild-goose chase after an already fixed bug.

Hopefully this addition is enough to avoid this wrong expectation.

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

@Mikolaj

Mikolaj commented Jun 18, 2026

Copy link
Copy Markdown
Member

Thank you for the PR. Is it ready for review? If so, please add the review-needed label.

@ninioArtillero

ninioArtillero commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator Author

@Mikolaj It is ready for review, but I don't have the necessary permissions to add a label.

@Mikolaj

Mikolaj commented Jun 18, 2026

Copy link
Copy Markdown
Member

Oh, yes! Let's remedy that. Please kindly accept an invitations to the cabal of cabal github project contributors.

@Mikolaj

Mikolaj commented Jun 18, 2026

Copy link
Copy Markdown
Member

@philderbeast: you recently overhauled this functionality. Would you mind confirming the docs addition is correct? Anything else we could clarify while we are at it?

@philderbeast

Copy link
Copy Markdown
Collaborator

@Mikolaj I'm not that familiar with probing up the tree for the project files. I think that stuff was changed in:

- Add `--project-dir` flag [#7695](https://github.com/haskell/cabal/issues/7695) [#7940](https://github.com/haskell/cabal/issues/7940) [#8454](https://github.com/haskell/cabal/pull/8454)
- Added `--project-dir` flag for specifying the project's root directory
- Deprecated using `--project-file` with an absolute filepath without also using `--project-dir`.

I am working on #11898 and #11888. This includes getting close to how and when the .local and .freeze files are parsed and checked. I'll try to look at and test what this doc change mentions while I'm at it.

@ninioArtillero

Copy link
Copy Markdown
Collaborator Author

I sent an LLM looking for evidence supporting this addition. It pointed at the following places, sharing in case it is of some help to you @philderbeast :

  1. Project root = directory containing cabal.project — DistDirLayout.hs:180-182:

(projectRootDir, projectFile) = case projectRoot of
ProjectRootImplicit dir -> (dir, dir </> defaultProjectFile)
ProjectRootExplicit dir file -> (dir, dir </> file)

  1. Auxiliary files are derived from the same path — DistDirLayout.hs:187-188:

distProjectFile :: String -> FilePath
distProjectFile ext = projectFile <.> ext

So distProjectFile "local" = /cabal.project.local, distProjectFile "freeze" = /cabal.project.freeze. All auxiliary files share the same directory as cabal.project. No other locations are checked.

  1. All three are always read from the project root — ProjectConfig.hs:774-777:

local <- readProjectLocalConfigOrDefault ... -- reads /cabal.project
freeze <- readProjectLocalFreezeConfig ... -- reads /cabal.project.freeze
extra <- readProjectLocalExtraConfig ... -- reads /cabal.project.local

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