lune icon indicating copy to clipboard operation
lune copied to clipboard

Cache & REPL history paths do not respect XDG

Open uncenter opened this issue 1 year ago • 1 comments

These typedef and build target directories are hardcoded to be in ~/.lune/.

https://github.com/lune-org/lune/blob/5d1401cdf611cc9f215f03bdf16ada0e77717edf/crates/lune/src/cli/setup.rs#L171-L176 https://github.com/lune-org/lune/blob/5d1401cdf611cc9f215f03bdf16ada0e77717edf/crates/lune/src/cli/build/target.rs#L13

And the REPL history file is hardcoded at ~/.lune_history. https://github.com/lune-org/lune/blob/5d1401cdf611cc9f215f03bdf16ada0e77717edf/crates/lune/src/cli/repl.rs#L26-L29

The directories crate in use in Lune at the moment can support XDG_* environment variables, but only does so on Linux - this means macOS users would not have their preferences respected. I made my own user_dirs crate as an alternative that solves that issue of XDG on macOS not being respected, and there is the slightly more well known etcetera library that does so as well. I'm sure there are others I'm not aware of, and it isn't too complicated to implement this in-house in this repository.

Ideally the typedef/build files would be cached in $XDG_CACHE_HOME/lune/, and the REPL history file at $XDG_STATE_HOME/lune/lune_history (following fish shell's lead here of $XDG_STATE_HOME/fish/fish_history fwiw). These locations could default back to the current hardcoded paths if the XDG_* variables are not present.

It also may be worth considering LUNE_CACHE and LUNE_HISTORY environment variables, for setting the cache directory and history file paths respectfully, as some other programs do. I have no opinion on the matter but it is worth mentioning when bringing up this topic.

uncenter avatar Feb 08 '25 20:02 uncenter

Sounds like a good improvement to me. For generated type definitions specifically though, these do need to stay in the home dir to be compatible cross-platform with tooling such as Luau LSP which has special casing for ~

filiptibell avatar Mar 24 '25 18:03 filiptibell