Tracking Issue for `std::fs::HomeDirs` (`feature(fs_home_dirs)`)
Open
@CAD97 is already working on this.
Since Aug 31, 2026.
C-tracking-issue
S-tracking-unimplemented
T-libs
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Feature gate: #![feature(fs_home_dirs)]
This is a tracking issue for std::fs::HomeDirs and related functionality.
Sister feature tracking issue: std::fs::MediaDirs
HomeDirs exposes common user directory paths useful for user application files. This supersedes the XDG APIs.
Public API
// mod std::fs
pub struct HomeDirs { /* ... */ }
impl HomeDirs {
fn empty() -> Self;
pub fn config_home(&self) -> Option<&Path>;
pub fn data_home(&self) -> Option<&Path>;
pub fn state_home(&self) -> Option<&Path>;
pub fn cache_home(&self) -> Option<&Path>;
pub fn set_config_home(&mut self, path: PathBuf) -> &mut Self;
pub fn set_data_home(&mut self, path: PathBuf) -> &mut Self;
pub fn set_state_home(&mut self, path: PathBuf) -> &mut Self;
pub fn set_cache_home(&mut self, path: PathBuf) -> &mut Self;
}
// mod std::os::darwin::fs
impl HomeDirsExt for HomeDirs { /* ... */ }
pub impl(self) trait HomeDirsExt {
fn sysdir() -> io::Result<Self>;
}
// mod std::os::unix::fs
impl HomeDirsExt for HomeDirs { /* ... */ }
pub impl(self) trait HomeDirsExt {
fn xdg() -> io::Result<Self>;
fn runtime_home(&self) -> Option<&Path>;
fn config_dirs(&self) -> Option<XdgDirs<'_>>;
fn data_dirs(&self) -> Option<XdgDirs<'_>>;
fn set_runtime_home(&mut self, path: PathBuf) -> &mut Self;
fn set_config_dirs(&mut self, paths: OsString) -> &mut Self;
fn set_data_dirs(&mut self, paths: OsString) -> &mut Self;
}
pub struct XdgDirs<'a> { /* ... */ }
impl Iterator for XdgDirs<'a> {
type Item = &'a Path;
/* ... */
}
// mod std::os::windows::fs
impl HomeDirsExt for HomeDirs { /* ... */ }
pub impl(self) trait HomeDirsExt {
fn appdata_env() -> io::Result<Self>;
fn known_folders() -> io::Result<Self>;
}
Steps / History
(Remember to update the S-tracking-* label when checking boxes.)
- ACP: https://github.com/rust-lang/libs-team/issues/830
- Implementation: https://github.com/rust-lang/rust/pull/158936
- Final comment period (FCP)^1
- Stabilization PR
Unresolved Questions
- Is this API sufficiently platform-agnostic and resilient to new OS developments to live in std?
- The author believes so. T-libs-api has approved in-tree experimentation.
- I (@CAD97) think that a
fn take(&mut self) -> Selfmethod would be useful for builder-API style usage of theset_*methods. T-libs-api agreed we don't. I will defer to T-libs-api here, but want to log this note. - Should the Unix
HomeDirsExtprovidefn bin_home(&self) -> Option<&Path>? The XDG spec defines a bin home path to specifically$HOME/.local/binand$XDG_BIN_HOMEis a non-standard extension. - Should the Windows
HomeDirsExtprovide access to more of the PERUSERKNOWNFOLDERIDs? - The XDG base directories spec is technically platform-agnostic as of the (unversioned) update to specify directory lists in terms of how
PATHis handled instead of mandating:as a separator. ShouldHomeDirs::xdg()be platform agnostic or limited to the Unix extension trait?- This has bearing on whether
XdgDirscan iterate&Pathor if it needs to iteratePathBuflikeenv::split_pathsdoes.
- This has bearing on whether
- APIs for media dirs are out of scope for this tracking issue; for those, see https://github.com/rust-lang/rust/issues/162083.
- APIs for app dirs (which are subdirs of the home dirs) is explicitly out of scope for this tracking issue and should get a new ACP.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.