diff --git a/Cargo.toml b/Cargo.toml index bd9d554..ec9813b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,8 +12,8 @@ categories = ["os", "filesystem"] keywords = ["which", "which-rs", "unix", "command"] [dependencies] -dirs = "5.0.1" either = "1.6.1" +home = "0.5.5" regex = { version = "1.5.5", optional = true } rustix = { version = "0.38.10", default-features = false, features = ["fs", "std"] } diff --git a/src/finder.rs b/src/finder.rs index 06b2a77..80e462f 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; @@ -249,3 +248,15 @@ fn correct_casing(mut p: PathBuf) -> PathBuf { fn correct_casing(p: PathBuf) -> PathBuf { p } + +#[cfg(any(unix, target_os = "redox", windows))] +fn home_dir() -> Option { + home::home_dir() +} + +// This is for wasm platform (and maybe others) where home directory is not +// defined. See: https://github.com/rust-lang/cargo/issues/12297 +#[cfg(not(any(unix, target_os = "redox", windows)))] +fn home_dir() -> Option { + None +}