Skip to content

Add support for XDG_CONFIG_HOME in justfile search paths#2692

Open
pojknamn wants to merge 3 commits intocasey:masterfrom
pojknamn:xdg_config_feature
Open

Add support for XDG_CONFIG_HOME in justfile search paths#2692
pojknamn wants to merge 3 commits intocasey:masterfrom
pojknamn:xdg_config_feature

Conversation

@pojknamn
Copy link
Copy Markdown

@pojknamn pojknamn commented Apr 2, 2025

  • Added support for checking $XDG_CONFIG_HOME/just/justfile path when looking for config files with global option
  • add a few tests

Fixes #2687

feedback welcome, this is my first time contributing rust

.join(DEFAULT_JUSTFILE_NAME),
);

if let Some(xdg_config_home) = std::env::var_os("XDG_CONFIG_HOME") {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is the goal to add the option of XDG base directory specification-compliant path for global justfile, or only to use XDG_CONFIG_HOME literally as per documentation?

If the former, checking whether XDG_CONFIG_HOME is set is not the only condition to consider - see related discussion in #2536

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

So if I understand the conversation from the linked PR, it doesn't seem like getting full XDG-compliant paths is that hard. The only two concrete examples I could find were relative paths which are not allowed, and empty paths (the environment variable is set, but to an empty value). So you just take the contents of the environment variable, filter out any non-absolute or empty paths, and then default to ~/.config if there's nothing left. Did I get that correct?

Just my $0.02 as the issue submitter, I don't really care either way about this. I love rigorous standards, and it seems good to follow the standard, but if we're not too strict about it, then I can still make sure that the environment variable is set correctly on my end, and everything still works just fine for me. As long as there's something I can fix with my environment, then I can deal with whatever. I just need the documented example to work on all platforms. :)

And thanks for @laniakea64 for doing this, I was going to see about patching this, but I have never done anything in rust, and I hadn't gotten around to it yet. ❤️

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So if I understand the conversation from the linked PR, it doesn't seem like getting full XDG-compliant paths is that hard. ... So you just take the contents of the environment variable, filter out any non-absolute or empty paths, and then default to ~/.config if there's nothing left. Did I get that correct?

Yes, you are correct about full XDG spec compliance.

And thanks for @laniakea64 for doing this, I was going to see about patching this, but I have never done anything in rust, and I hadn't gotten around to it yet. ❤️

😕 I wasn't involved in authoring this PR

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

My bad, lol... Thanks to @pojknamn for writing this!!! ❤️ You're a hero!

@malikoth
Copy link
Copy Markdown

malikoth commented Oct 7, 2025

Obviously this needs to rebased onto latest code, but other than that, is this something you'd merge, @casey? I haven't actually needed this for a while as I've primarily been using Windows for a bit, but now I'm back on a mac, and would dearly appreciate having this fix merged.

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.

Error: Global justfile not found

4 participants