Skip to content

cabal update: don't show comment with builddir in the default config #11067

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

Merged
merged 1 commit into from
Jul 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions cabal-install/src/Distribution/Client/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1782,9 +1782,16 @@ showConfigWithComments comment vals =
(fmap (field . savedConfigureFlags) mcomment)
((field . savedConfigureFlags) vals)

-- skip fields based on field name. currently only skips "remote-repo",
-- because that is rendered as a section. (see 'ppRemoteRepoSection'.)
skipSomeFields = filter ((/= "remote-repo") . fieldName)
-- Skip fields based on field name.
skipSomeFields =
filter
( ( `notElem`
[ "remote-repo" -- rendered as a section (see 'ppRemoteRepoSection')
, "builddir" -- no effect in config file (see Note [reading project configuration])
]
)
. fieldName
)

-- | Fields for the 'install-dirs' sections.
installDirsFields :: [FieldDescr (InstallDirs (Flag PathTemplate))]
Expand Down
1 change: 0 additions & 1 deletion cabal-install/tests/IntegrationTests2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2675,7 +2675,6 @@ testConfigOptionComments = do
"-- username" `assertHasCommentLine` "username"
"-- password" `assertHasCommentLine` "password"
"-- password-command" `assertHasCommentLine` "password-command"
"-- builddir" `assertHasCommentLine` "builddir"

" -- hoogle" `assertHasCommentLine` "hoogle"
" -- html" `assertHasCommentLine` "html"
Expand Down
12 changes: 12 additions & 0 deletions changelog.d/pr-11067
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
synopsis: `cabal update`: create default config without comment about `builddir`
packages: cabal-install
prs: #11067
issues: #11050
description: {
When calling `cabal update` with an empty state (empty `CABAL_DIR` or new
machine), cabal writes out a default config file with many fields
commented out to show their defaults. This suggests that the user can
uncomment the field and override the default. This is wrong for fields
that aren't allowed in the config file like `builddir`. This patch
avoids generating a comment with `builddir` in the default config.
}
Loading