Skip to content

Conversation

@pd93
Copy link
Member

@pd93 pd93 commented Aug 19, 2025

Fixes #2390 by changing the name of the $XDG_CONFIG_HOME/task config to taskrc.yml or taskrc.yaml (without the preceding .).

@vmaerten @panchoh w.r.t discussion in #2390, I'm not against config.yml, but after a bit of thinking I actually feel like ripgrep might have got this right. The naming consistency is valuable IMO. It lets you know that you're editing the same kind of file with the same schema and I think $XDG_CONFIG_HOME/task/taskrc.yml is the way to go. Happy to be outvoted on this though!

Once agreed and merged, I will open a PR to the schemastore repo.


Also the related discussion on Discord around the inclusion of the $HOME directory when running from a directory that does not have $HOME as a parent.

See updated docs for a full description.

@pd93 pd93 requested review from andreynering and vmaerten August 19, 2025 14:55
@vmaerten
Copy link
Member

First of all, I agree with taskrc.yml as filename.
@andreynering suggested here that we could support both (with dot and without) everywhere : #2390 (comment)

Project without a .taskrc.yml

  • Walk up the directory tree to find a .taskrc.yml.
  • Read $HOME/.taskrc.yml if is not a parent of the current directory.
  • Read $XDG_CONFIG_HOME/task/taskrc.yml.

Project with a .taskrc.yml

  • Do not walk up the tree, since the config is already defined locally.
  • Optionally merge with $XDG_CONFIG_HOME/task/taskrc.yml if it exists.

Windows-specific case

If a user has a local .taskrc.yml in their project but no XDG_CONFIG_HOME,
they cannot define a global Task configuration.
In this scenario, $HOME/.taskrc.yml would not be merged with the local config (assuming the project is under $HOME/xxx/xxxx/xxxx.
You may need to remove the condition !strings.Contains(home, dir)

Question:
Am I correct in this interpretation?
Do we want to support this use case?

@pd93
Copy link
Member Author

pd93 commented Aug 19, 2025

Happy to debate if it should work differently, but currently it works like this:

  • Walk up the directory tree to find all .taskrc.yml files.
    • If current dir is a child of $HOME then any .taskrc.yml is automatically included in this walk.
    • Otherwise, we explicitly add any .taskrc.yml in $HOME.
  • Look for taskrc.yml in XDG_CONFIG_HOME

We then gather all the files we found merge them in reverse order. Starting with $XDG_CONFIG_HOME (as the lowest priority), then $HOME, then files in parent directories and finally any files in the current directory.

If a user has a local .taskrc.yml in their project but no XDG_CONFIG_HOME,
they cannot define a global Task configuration.
In this scenario, $HOME/.taskrc.yml would not be merged with the local config (assuming the project is under $HOME/xxx/xxxx/xxxx.

I think the misunderstanding here is that it is gathering all files in parent directories, not just the first one it finds. Whether this is correct is up for debate. However, as it stands, if $XDG_CONFIG_HOME is not set, we will always use $HOME if set - Either via the recursive search or by explicitly pulling it in.

Using the example from the updated docs:

# $XDG_CONFIG_HOME/task/taskrc.yml
# lowest priority global config
option_1: foo
option_2: foo
option_3: foo
# $HOME/.taskrc.yml
option_1: bar
option_2: bar
# $HOME/path/to/project/.taskrc.yml
# highest priority project config
option_1: baz

You would end up with the following configuration:

option_1: baz # Taken from $HOME/path/to/project/.taskrc.yml
option_2: bar # Taken from $HOME/.taskrc.yml
option_3: foo # Taken from $XDG_CONFIG_HOME/task/.taskrc.yml

@vmaerten
Copy link
Member

You are totally right! I'm dumb 🤦‍♂️
It's good for me then :)
Sorry!

Copy link
Member

@vmaerten vmaerten left a comment

Choose a reason for hiding this comment

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

🚀

@pd93 pd93 merged commit 39462cb into main Aug 20, 2025
13 checks passed
@pd93 pd93 deleted the change-xdg-taskrc-naming branch August 20, 2025 11:13
pd93 added a commit that referenced this pull request Aug 20, 2025
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.

XDG_CONFIG_HOME/task config should not be a hidden file

3 participants