Welcome! Please see the About page for a little more info on how this works.

+2 votes
in Tools by

XDG_CONFIG_HOME does not need to be set explicitly, and tools follow XDG spec should just write to $HOME/.config/clojure

Right now, if XDG_CONFIG_HOME is not set, it just writes to $HOME/.clojure

more context here also:
https://clojureverse.org/t/opinion-about-xdg-support-by-the-clojure-tools-deps-cli/9814/3

by
Do XDG systems always have $HOME/.config even if it is empty? If not, then what if the CLI were the first tool to run in a new user account -- it wouldn't find $HOME/.config and XDG_CONFIG_HOME wouldn't be set, so wouldn't it deduce this was not an XDG system and write to $HOME/.clojure instead of $HOME/.config/clojure? (this question would apply to all tools in such an environment, so I'm wondering what creates $HOME/.config in the first place)
by
According to arch wiki, 'only XDG_RUNTIME_DIR is set by default through pam_systemd(8). It is up to the user to explicitly define the other variables according to the specification.'


https://wiki.archlinux.org/title/XDG_Base_Directory

But in reality, if you check how apps imp XDG spec, most of them just go by following logic without check XDG_RUNTIME_DIR i think.

1. if HOME/.clojure exist, use legacy path
2. else use XFG spec, (or (getenv XDG_CONFIG_HOME)  (path HOME/.config/clojure))

XDG_CONFIG_HOME (and the other xdg vars) are unset on most distros, and there are defined defaults that should be used instead. Here's the part clj tools get confused, because it should just write to my HOME/.config/clojure instead of fall back to legacy path.
by
On an arbitrary system, before installing Clojure, $HOME/.clojure will not exist -- so you are essentially requesting Clojure CLI switch to XDG on all systems, based on that logic in your comment.

Did I misunderstand you?

1 Answer

0 votes
by

The question continues to be: how could the Clojure CLI definitively know that you wish to use XDG configuration options. If there is a definitive answer to that question, I'd be happy to use that to select this behavior. We're not going to change that to be the default.

Another option would be to have a Clojure CLI specific environment variable that you could set to do that (but you're going to have to take that action).

by
In both cases, the user has to explicitly do something - either create ~/.config/clojure or set XDG_CONFIG_HOME. Between those, setting the env var seems more obvious to me.

I don't think it's confusing now, this is documented (https://clojure.org/reference/deps_and_cli#deps_sources) and seems very clear to me:

    User - cross-project configuration (typically tools)
        Locations used in this order:
            If $CLJ_CONFIG is set, then use $CLJ_CONFIG (explicit override)
            If $XDG_CONFIG_HOME is set, then use $XDG_CONFIG_HOME/clojure (Freedesktop conventions)
            Else use $HOME/.clojure (most common)
by
Yes, it is documented. That's good. But I think this is kind of a proposition to change the current behavior. Why? Just because $XDG_CONFIG_HOME is meant to be an option for the user to overwrite the system behavior, independently of Clojure: I, as an XDG user, can change the location of the config folder by defining the environment variable XDG_CONFIG_HOME. It is about changing it more than actually setting it.

But the current documented behavior of Clojure interprets that variable like that is the only way to set the XDG config folder, which is not the case. This causes something that should be optional for an XDG user to become mandatory if the user wants Clojure to play the game.
by
I am still asking the exact same question I asked at the very top of this thread - how can the Clojure CLI know that you want to use XDG config? If there is some other answer to that question, then I'm happy to change the second if condition in that logic. I'm not changing the current behavior otherwise.
by
I gave my answer to this question but maybe it got lost in the back and forth. Here's what I think folks are asking for -- and certainly what I would prefer at this point:

    User - cross-project configuration (typically tools)
        Locations used in this order:
            If $CLJ_CONFIG is set, then use $CLJ_CONFIG (explicit override) -- no change
            If $XDG_CONFIG_HOME is set, then use $XDG_CONFIG_HOME/clojure -- no change
            If $HOME/.config/clojure exists, then use it (Freedesktop conventions) -- **new**
            Else use $HOME/.clojure (most common) -- no change

That 3rd condition could also be:

            If $HOME/.clojure does not exist but $HOME/.config/clojure exists, then use the latter (Freedesktop conventions)

If neither directory exists and no relevant env vars are set, use $HOME/.clojure as now.

If $HOME/.clojure exists and no relevant env vars are set, use $HOME/.clojure as now.

If $HOME/.clojure does not exist but $HOME/.config/clojure does (and no relevant env vars are set), use $HOME/.config/clojure (XDG style -- this is the requested change).

Hopefully that makes things clearer? (and hopefully the XDG advocates in this thread can confirm that's right/acceptable)

And to clarify the problem for XDG users right now:

If they move $HOME/.clojure to $HOME/.config/clojure but do not set the (optional) XDG_CONFIG_HOME env var, the CLI creates $HOME/.clojure afresh and ignores the XDG convention folder.
by
As I said above "If $HOME/.config/clojure exists" does not seem to tell you that it is an XDG system and still requires you to actively do a thing on your system, so does not seem to answer the original ask. So, this does not seem like a good answer. You say that moving your .clojure directory is the problem XDG users have, but I don't agree and that seems at odds with the original question, which was "XDG_CONFIG_HOME does not need to be set explicitly, and tools follow XDG spec should just write to $HOME/.config/clojure". So, looking for some better answer than this.
...