Follow XDG base directory specification instead of using ~/.step
What would you like to be added
On Linux, Step CLI should follow the XDG Base Directory specification for storing data (essentially, use $XDG_CONFIG_HOME/step rather than ~/.step by default).
I am aware you can specify a custom path with $STEPPATH, but the XDG spec is a standard that has predictable locations for users without further configuration. $STEPPATH should probably still override it if set though.
Why this is needed
This reduces clutter in the user's home directory and gives them more flexibility in deciding where and how to store their data.
If backwards-compatibility is an issue, I'd suggest using ~/.step if that location exists, and otherwise using the above.
Similar issue: https://github.com/smallstep/certificates/issues/386.
Long term, adding $XDG_CONFIG_HOME to the resolution path is probably the right fix. Something like:
- If
$STEPPATHexists then use$STEPPATH. - If
$XDG_CONFIG_HOMEexists then use$XDG_CONFIG_HOME. - Use
~/.step.
Our hesitance here is around taking on OS specific dependencies. We encourage the use of $STEPPATH because it is OS agnostic and therefore the least amount of work for us as maintainers. This isn't to say that we shouldn't or won't do this -- just trying to give some background to our thought process and why we haven't already prioritized.
Disappointing. step joins only firefox and thunderbird as still polluting my homedir.
Long term, adding
$XDG_CONFIG_HOMEto the resolution path is probably the right fix.
And also XDG_DATA_HOME.
- If
$STEPPATHexists then use$STEPPATH.- If
$XDG_CONFIG_HOMEexists then use$XDG_CONFIG_HOME.- Use
~/.step.
FWIW, this is not how this is not exactly how the XDG base-dir spec works. If an XDG_* env var is not defined, the program must fallback to the specified defaults:
| env | fallback |
|---|---|
| XDG_DATA_HOME | ~/.local/share |
| XDG_CONFIG_HOME | ~/.config |
| XDG_STATE_HOME | ~/.local/state |
| XDG_CACHE_HOME | ~/.cache |
So the directory layout mapping should look like the following:
| current | xdg compliant |
|---|---|
| ~/.step/config | ~/.config/step |
| ~/.step/certs | ~/.local/share/step/certs |
So the correct thing to do would be:
- If
STEPPATHis set then use${STEPPATH}. - Otherwise if the
${HOME}/.stepdirectory already exists, then use that for backward compatibility. - Otherwise use the specified XDG directories.
Our hesitance here is around taking on OS specific dependencies. We encourage the use of
$STEPPATHbecause it is OS agnostic and therefore the least amount of work for us as maintainers. This isn't to say that we shouldn't or won't do this -- just trying to give some background to our thought process and why we haven't already prioritized.
Fortunately, there's already a go package for that, so this would be a rather simple change to make implementation-wise.