Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache & REPL history paths do not respect XDG #300

Open
uncenter opened this issue Feb 8, 2025 · 0 comments
Open

Cache & REPL history paths do not respect XDG #300

uncenter opened this issue Feb 8, 2025 · 0 comments

Comments

@uncenter
Copy link

uncenter commented Feb 8, 2025

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

let cache_dir = UserDirs::new()
.context("Failed to find user home directory")?
.home_dir()
.join(".lune")
.join(".typedefs")
.join(version_string);

pub static CACHE_DIR: Lazy<PathBuf> = Lazy::new(|| HOME_DIR.join(".lune").join("target"));

And the REPL history file is hardcoded at ~/.lune_history.

let history_file_path: &PathBuf = &UserDirs::new()
.context("Failed to find user home directory")?
.home_dir()
.join(".lune_history");

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant