elvish icon indicating copy to clipboard operation
elvish copied to clipboard

Where should packages store their data

Open href opened this issue 6 years ago • 9 comments

I needed to store some state in my elvish-gitstatus package and I used the following place:

~/.elvish/package-data/gitstatus

This is super low-priority, but I was wondering: Does anyone have a better idea? Is there already a common place where others store their state?

href avatar Jun 02 '19 12:06 href

$XDG_DATA_HOME or .local/share

SolitudeSF avatar Jun 02 '19 13:06 SolitudeSF

I don't think there's an accepted convention, but storing it under ~/.elvish/ sounds reasonable. @SolitudeSF's suggestions make sense too. My aliases module stores the alias definitions under ~/.elvish/aliases/.

zzamboni avatar Jun 02 '19 13:06 zzamboni

One reason I didn't store it outside of .elvish is the thought that this keeps everything related to Elvish in one place, so cleanup is more straight-forward.

href avatar Jun 02 '19 15:06 href

I agree with that, I like having the whole config coalesced under a single directory. I am not much of a fan of XDG :)

zzamboni avatar Jun 02 '19 19:06 zzamboni

I just noticed you are another Swiss Elvish user 🇨🇭👍

zzamboni avatar Jun 02 '19 19:06 zzamboni

The Swiss do like high quality tools 😉

href avatar Jun 02 '19 20:06 href

As others said, there isn't any guidance at the moment yet.

xiaq avatar Jul 20 '19 13:07 xiaq

This should take into account the proposal to switch to using the XDG specification, issue #383. Since the data discussed in this issue is inherently per-system it should be stored someplace under ~/.local/share/elvish if the project adopts the XDG spec.

krader1961 avatar Sep 22 '20 03:09 krader1961

FWIW, I just started seeing this warning after upgrading elvish to the HEAD version a few minutes ago:

Warning: ~/.elvish will be ignored from Elvish 0.20.0.

The warning is due to the hardcoded path in package github.com/href/elvish-gitstatus:

# the folder where the gitstatusd related data is stored
var appdir = ~/.elvish/package-data/gitstatus

I would argue this should use $XDG_STATE_HOME (see https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html) or equivalent. The problem is that determining that directory is complicated since Elvish does not require the XDG env vars to be set and has fallbacks which differ between UNIX and Windows. It shouldn't be necessary for a module to implement this logic. See #1385 where I proposed exposing this information via the platform: module to make it trivial for modules to use whatever directory the current Elvish instance deems is appropriate for each type of file Elvish searches for (see https://elv.sh/ref/command.html).

For the moment I'm just going to locally edit github.com/href/elvish-gitstatus/gitstatus.elv but this needs to be resolved ASAP since ~/.elvish is now officially deprecated.

krader1961 avatar Jun 12 '22 04:06 krader1961