Skip to content

Credentials storage does not respect the XDG specification #108

@xfbs

Description

@xfbs

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

Metadata

Metadata

Assignees

Labels

complexity::lowIssues or ideas with a low implementation costcomponent::cliEverything related to the buffrs clitype::refactoringChanging the inner-workings of buffrs

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions