pub fn get_home_dir() -> Result<PathBuf>Expand description
Gets the home directory path for the current user.
This function returns the user’s home directory following platform conventions. It uses the appropriate environment variables and fallback mechanisms for each platform to reliably determine the home directory.
§Returns
The user’s home directory path, or an error if it cannot be determined
§Examples
use agpm_cli::utils::platform::get_home_dir;
let home = get_home_dir()?;
println!("Home directory: {}", home.display());
let agpm_dir = home.join(".agpm");
println!("AGPM directory would be: {}", agpm_dir.display());§Platform Behavior
- Windows: Uses
%USERPROFILE%environment variable - Unix/Linux: Uses
$HOMEenvironment variable - macOS: Uses
$HOMEenvironment variable
§Error Cases
- Home directory environment variable is not set
- Environment variable points to non-existent directory
- Permission denied accessing the home directory
§Use Cases
- Finding user configuration directories
- Resolving tilde (
~) in path expansion - Creating user-specific cache and data directories