Skip to content

Allows stack.yaml files to use !include directives - #6880

Merged
mpilgrem merged 2 commits into
commercialhaskell:masterfrom
flipstone:fix-6879
Apr 22, 2026
Merged

mpilgrem merged 2 commits into
commercialhaskell:masterfrom
flipstone:fix-6879

Conversation

@qxjit

@qxjit qxjit commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

This allows projects that maintain multiple stack.yaml files (e.g. for testing against multiple LTS versions) to reduce the duplication between them by using includes to share common parts.

!include may also be used in config.yaml files.

The use of !include interferes with the ability of the config set command to determine where to change a setting that has been read while parsing JSON, so thes makes config set raise error if !include appears in the file being updated.

Note: Fixes for the online documentation of the current Stack release
(https://docs.haskellstack.org/en/stable/) should target the 'stable' branch,
not the 'master' branch.

Please include the following checklist in your pull request:

  • Any changes that could be relevant to users have been recorded in ChangeLog.md.
  • The documentation has been updated, if necessary

Please also shortly describe how you tested your change. Bonus points for added tests!

Integration tests were added!

Fixes #6879

This allows projects that maintain multiple `stack.yaml` files (e.g.
for testing against multiple LTS versions) to reduce the duplication
between them by using includes to share common parts.

`!include` may also be used in `config.yaml` files.

The use of `!include` interferes with the ability of the `config set`
command to determine where to change a setting that has been read while
parsing JSON, so thes makes `config set` raise error if `!include`
appears in the file being updated.

Fixes commercialhaskell#6879
@mpilgrem

Copy link
Copy Markdown
Member

@qxjit, I am wondering if it is a bit harsh for stack config set always to decline to act if a !include tag is present. An alternative approach might be:

  • if the relevant key is present in the YAML file, stack config set acts; but
  • if the relevant key is absent and a !include tag is present, stack config set declines to act.

@qxjit

qxjit commented Apr 21, 2026

Copy link
Copy Markdown
Contributor Author

@mpilgrem I think that's a good idea. I'll make that change when I get a moment.

This moves the check for `!include` when executing `config set` to
after the detection of keys in the config so that values directly
present in the file can be set even when `!include` is present.

@mpilgrem mpilgrem left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some further comments prompted by the failing CI.

Comment thread tests/integration/tests/6879-stack-yaml-includes/files/stack-including-flags.yaml Outdated
Comment thread src/Stack/ConfigCmd.hs Outdated
Comment thread tests/integration/tests/6879-stack-yaml-includes/Main.hs
Comment thread tests/integration/tests/6879-stack-yaml-includes/Main.hs
@mpilgrem
mpilgrem merged commit 2dae2ba into commercialhaskell:master Apr 22, 2026
17 of 19 checks passed
@qxjit

qxjit commented Apr 22, 2026

Copy link
Copy Markdown
Contributor Author

@mpilgrem Thanks for taking care of the integration test failure. I was hoping to get to that today, but you beat me. ❤️

@qxjit
qxjit deleted the fix-6879 branch April 23, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support !include directives in stack.yaml and config.yaml

2 participants