diff --git a/Cargo.toml b/Cargo.toml index bd9d554..d01e01f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,11 +12,13 @@ categories = ["os", "filesystem"] keywords = ["which", "which-rs", "unix", "command"] [dependencies] -dirs = "5.0.1" either = "1.6.1" regex = { version = "1.5.5", optional = true } rustix = { version = "0.38.10", default-features = false, features = ["fs", "std"] } +[target.'cfg(any(windows, unix, target_os = "redox"))'.dependencies] +home = "0.5.5" + [target.'cfg(windows)'.dependencies] once_cell = "1" diff --git a/src/finder.rs b/src/finder.rs index 06b2a77..26e87c4 100644 --- a/src/finder.rs +++ b/src/finder.rs @@ -2,7 +2,6 @@ use crate::checker::CompositeChecker; use crate::error::*; #[cfg(windows)] use crate::helper::has_executable_extension; -use dirs::home_dir; use either::Either; #[cfg(feature = "regex")] use regex::Regex; @@ -16,6 +15,15 @@ use std::fs; use std::iter; use std::path::{Component, Path, PathBuf}; +// Home dir shim, use home crate when possible. Otherwise, return None +#[cfg(any(windows, unix, target_os = "redox"))] +use home::home_dir; + +#[cfg(not(any(windows, unix, target_os = "redox")))] +fn home_dir() -> Option { + None +} + pub trait Checker { fn is_valid(&self, path: &Path) -> bool; }