From 36cb494e91f4692ff510fae3ef051dd94d109b55 Mon Sep 17 00:00:00 2001 From: Michael Farrell Date: Wed, 18 Dec 2024 16:46:30 +1000 Subject: [PATCH] Switch to env_home crate. Fixes #104 --- Cargo.toml | 2 +- src/finder.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 963bb7a..6b1a5e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ regex = { version = "1.10.2", optional = true } tracing = { version = "0.1.40", default-features = false, optional = true } [target.'cfg(any(windows, unix, target_os = "redox"))'.dependencies] -home = "0.5.9" +env_home = "0.1.0" [target.'cfg(any(unix, target_os = "wasi", target_os = "redox"))'.dependencies] rustix = { version = "0.38.30", default-features = false, features = ["fs", "std"] } diff --git a/src/finder.rs b/src/finder.rs index c29ea1d..66568f5 100644 --- a/src/finder.rs +++ b/src/finder.rs @@ -15,12 +15,12 @@ use std::fs; use std::iter; use std::path::{Component, Path, PathBuf}; -// Home dir shim, use home crate when possible. Otherwise, return None +// Home dir shim, use env_home crate when possible. Otherwise, return None #[cfg(any(windows, unix, target_os = "redox"))] -use home::home_dir; +use env_home::env_home_dir; #[cfg(not(any(windows, unix, target_os = "redox")))] -fn home_dir() -> Option { +fn env_home_dir() -> Option { None } @@ -266,7 +266,7 @@ fn tilde_expansion(p: &PathBuf) -> Cow<'_, PathBuf> { let mut component_iter = p.components(); if let Some(Component::Normal(o)) = component_iter.next() { if o == "~" { - let mut new_path = home_dir().unwrap_or_default(); + let mut new_path = env_home_dir().unwrap_or_default(); new_path.extend(component_iter); #[cfg(feature = "tracing")] tracing::trace!(