Skip to main content

home_dir

Function home_dir 

Source
pub fn home_dir() -> Option<PathBuf>
Expand description

Return the current user’s home directory, when it can be determined.

On Unix, this prefers passwd-database lookup for the invoking user. During sudo sessions it uses SUDO_UID to find the original user’s home, falling back to SUDO_HOME and then HOME when passwd lookup is unavailable. On Windows, it reads USERPROFILE. On other targets (for example wasm32), it returns None.

StackDetector::new calls this once to set its home ceiling. Callers of find_project_root or resolve_project_root should call it once and reuse the result.