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

Credentials storage does not respect the XDG specification #108

Open
xfbs opened this issue Oct 10, 2023 · 2 comments
Open

Credentials storage does not respect the XDG specification #108

xfbs opened this issue Oct 10, 2023 · 2 comments
Assignees
Labels
complexity::low Issues or ideas with a low implementation cost component::cli Everything related to the buffrs cli type::refactoring Changing the inner-workings of buffrs

Comments

@xfbs
Copy link
Contributor

xfbs commented Oct 10, 2023

Currently, the credentials are stored in a hard-coded path determined by the $BUFFRS_HOME variable, or in ~/.buffrs/credentials.toml, see this code. While this is initially a sensible approach, there are some improvements that could be made.

Issues

Depending on the operating system that you are using, you may not want to store things in your home directory. Some operating systems do not understand the concept of dotfiles (files or folders, which are hidden by default due to a leading dot in their name). Some people may prefer to not clobber their home directories with configuration, but rather store it somewhere else.

In general, it is warmly recommended to adhere to a standard when it comes to storing configuration rather than "clobbering" user's home directories with it. See also

Standard

For this reason, the XDG group has a specification called the XDG Base Directory Specification which sets standards that applications should respect. One of these standards defines where configuration should be stored. The default location as per this standard would be ~/.config/buffrs/credentials.toml, but the spec also defines environment variables that can be set to change this.

Similarly, Windows has the KNOWNFOLDERID API and macOS the Standard Directories.

Solution

We can use the dirs crate to consume these standards. Another crate offered by the same team is directories, which should make it even easier for us.

Notes

Note that many applications still do not respect the XDG standard, including my beloved editor vim. It is not the end of the world if we do not adhere to them. But I do believe that it is a good standard and that there are few reasons not to stick to it. Ideally, we can stick to it in a backwards-compatible way, such that the application would prefer configuration created in the XDG-compatible paths, but would also search the current locations.

See Also

@xfbs xfbs self-assigned this Oct 10, 2023
@mara-schulke mara-schulke added complexity::low Issues or ideas with a low implementation cost component::cli Everything related to the buffrs cli type::refactoring Changing the inner-workings of buffrs and removed enhancement labels Oct 10, 2023
@mara-schulke
Copy link
Contributor

Sounds sensible to me!

@poliorcetics
Copy link
Contributor

We can use the dirs crate to consume these standards. Another crate offered by the same team is directories, which should make it even easier for us.

Both crates are not very nice to use for macOS users: dirs-dev/directories-rs#47

buffrs is a binary tool so we probably want it to respect the XDG spec even on macOS (at least for the config, the cache can be wherever, as users we don't have to interact with it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity::low Issues or ideas with a low implementation cost component::cli Everything related to the buffrs cli type::refactoring Changing the inner-workings of buffrs
Projects
None yet
Development

No branches or pull requests

3 participants