k3s-io / k3s

Lightweight Kubernetes
https://k3s.io
Apache License 2.0
27.56k stars 2.31k forks source link

Respect XDG base directory #10529

Open docabci opened 1 month ago

docabci commented 1 month ago

k3s use $HOME/.rancher/k3s as data dir.

It should be $XDG_DATA_HOME/rancher/k3s with $HOME/.local/rancher/k3s if XDG_DATA_HOME is not defined.

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

brandond commented 1 month ago

Can you provide a list of which distros set this, and why we would want to support it over $HOME? I'm not aware of it being set on any of the distros we currently test on or support.

docabci commented 1 month ago

The basedir spec is for applications not distros. The idea is :

Distros like Debian or Arch Linux generally ask upstream project to implements this rather than patching it.

brandond commented 1 month ago

Huh, interesting. I see other XDG env vars (such as XDG_RUNTIME_DIR) set on my session, but not XDG_DATA_HOME; I was naively expecting it to be set to an appropriate default on distros that encourage its use.

I would worry about this being a breaking change, we would probably want to check for the current default and continue to use that if it exists, in case anyone is currently running k3s out of $HOME.