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

+4 votes
in Tools by
retagged 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
The concern of forcing users into XDG is very clear.

Every system seems to have different flavors of XDG_ variables set by default (Nix on Darwin is setting XDG_CONFIG_DIRS and XDG_DATA_DIRS).

If we're willing to rely more on the XDG naming and conventions, we could improve our coverage of the unambiguous use cases.

More concretely:

            If $CLJ_CONFIG is set, then use $CLJ_CONFIG (explicit override)
            If any $XDG_* is set, then follow XDG conventions ($XDG_CONFIG_HOME/clojure or ~/.config/clojure when unset) -- **change**
            Else use $HOME/.clojure (most common)

N.B.: XDG_* may also stand for only the 7 existing documented variables
by
The more I think and read about this specification (xdg base dirs), the more I think it is more an option of the application to choose whether to follow the specs or not, and the system has no responsibility in this regard.

So the idea of adding a flag could be the way to go.  This give the users the option to install the clojure cli wiht full support or not of XDG, and also to the package managers (think about debian Clojure package maintainer). Similar to the `--prefix` flag.

Here is the idea in a commit: easier to explain in code: https://github.com/jgomo3/brew-install/commit/bfae7f15291826c0a27e2a76d42a5275493c7da2

One important thing is that the idea is not to change the current behavior.

Note: the code is not tested, and it is not a Pull Request.  It is just to support this comment.
by
Choosing at install time is a good idea. If you're interested in working on a patch for it, would be happy to have you do so.
by
edited by
Yes, thank you.  I would be glad to work on the patch.

I'll follow these instructions: https://clojure.org/dev/dev
...