From 2dd0ce72ca70e56681325fcdf214de2dabd0d6e5 Mon Sep 17 00:00:00 2001 From: jdx <216188+jdx@users.noreply.github.com> Date: Fri, 20 Dec 2024 17:25:41 +0000 Subject: [PATCH] chore: switch from home -> homedir crate home is apparently not to be used outside of cargo --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/env.rs | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3bd175ed1b..7d42c76130 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2631,7 +2631,7 @@ dependencies = [ "glob", "globset", "heck 0.5.0", - "home", + "homedir", "humantime", "indenter", "indexmap 2.7.0", diff --git a/Cargo.toml b/Cargo.toml index fd16cecf41..e3fcb5319f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,6 +68,7 @@ digest = "0.10.7" dotenvy = "0.15" duct = "0.13" either = { version = "1", features = ["serde"] } +homedir = "0.3" # expr-lang = { path = "../expr-lang" } expr-lang = "0.2" eyre = "0.6" @@ -78,7 +79,6 @@ git2 = "<1" glob = "0.3" globset = "0.4" heck = "0.5" -home = "0.5" humantime = "2" indenter = "0.3" indexmap = { version = "2", features = ["serde"] } diff --git a/src/env.rs b/src/env.rs index 8dd8e0d255..21288afa8e 100644 --- a/src/env.rs +++ b/src/env.rs @@ -23,8 +23,12 @@ pub static SHELL: Lazy = Lazy::new(|| var("COMSPEC").unwrap_or_else(|_| pub static HOME: Lazy = Lazy::new(|| PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("test")); #[cfg(not(test))] -pub static HOME: Lazy = - Lazy::new(|| home::home_dir().unwrap_or_else(|| PathBuf::from("/"))); +pub static HOME: Lazy = Lazy::new(|| { + homedir::my_home() + .ok() + .flatten() + .unwrap_or_else(|| PathBuf::from("/")) +}); pub static EDITOR: Lazy = Lazy::new(|| var("VISUAL").unwrap_or_else(|_| var("EDITOR").unwrap_or_else(|_| "nano".into())));