pub fn real_home_dir() -> Option<PathBuf>Expand description
Get the real user’s home directory, accounting for sudo scenarios.
When running under sudo, dirs::home_dir() returns root’s home directory
because $HOME is set to /root. This function checks for SUDO_USER and
attempts to get the actual invoking user’s home directory instead.
Priority:
- If SUDO_USER is set, try to get that user’s home directory
- Fall back to dirs::home_dir() (which reads $HOME or uses system APIs)