From 0457c38d4fad9834770377bfd4e4e6a4d6ecadf7 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Thu, 2 Jan 2025 10:06:35 -0500 Subject: [PATCH] refactor: remove use of home crate (#27516) The two places mentioned in the issue are now consolidated. Closes https://github.com/denoland/deno/issues/24385 --- Cargo.lock | 21 ++++----------------- Cargo.toml | 2 +- ext/node/Cargo.toml | 3 +-- ext/node/ops/os/mod.rs | 7 ++++++- runtime/permissions/lib.rs | 3 +-- 5 files changed, 13 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 30f4f0d394..eaba6115da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1355,7 +1355,7 @@ dependencies = [ "typed-arena", "uuid", "walkdir", - "which 4.4.2", + "which", "winapi", "winres", "zeromq", @@ -1996,7 +1996,6 @@ dependencies = [ "faster-hex", "h2 0.4.4", "hkdf", - "home", "http 1.1.0", "http-body-util", "hyper 1.4.1", @@ -2179,7 +2178,7 @@ dependencies = [ "percent-encoding", "serde", "thiserror 2.0.3", - "which 4.4.2", + "which", "winapi", ] @@ -2268,7 +2267,7 @@ dependencies = [ "tokio-metrics", "twox-hash", "uuid", - "which 4.4.2", + "which", "winapi", "windows-sys 0.59.0", ] @@ -8432,7 +8431,7 @@ dependencies = [ "miniz_oxide", "once_cell", "paste", - "which 6.0.1", + "which", ] [[package]] @@ -8742,18 +8741,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "which" -version = "4.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" -dependencies = [ - "either", - "home", - "once_cell", - "rustix", -] - [[package]] name = "which" version = "6.0.1" diff --git a/Cargo.toml b/Cargo.toml index 117a1bf6a8..722fe10c60 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -212,7 +212,7 @@ url = { version = "2.5", features = ["serde", "expose_internals"] } uuid = { version = "1.3.0", features = ["v4"] } webpki-root-certs = "0.26.5" webpki-roots = "0.26" -which = "4.2.5" +which = "6" yoke = { version = "0.7.4", features = ["derive"] } zeromq = { version = "=0.4.1", default-features = false, features = ["tcp-transport", "tokio-runtime"] } zstd = "=0.12.4" diff --git a/ext/node/Cargo.toml b/ext/node/Cargo.toml index a3936af735..0f6ae1d7ab 100644 --- a/ext/node/Cargo.toml +++ b/ext/node/Cargo.toml @@ -49,7 +49,6 @@ errno = "0.2.8" faster-hex.workspace = true h2.workspace = true hkdf.workspace = true -home = "0.5.9" http.workspace = true http-body-util.workspace = true hyper.workspace = true @@ -93,7 +92,7 @@ simd-json = "0.14.0" sm3 = "0.4.2" spki.workspace = true stable_deref_trait = "1.2.0" -sys_traits = { workspace = true, features = ["real"] } +sys_traits = { workspace = true, features = ["real", "winapi", "libc"] } thiserror.workspace = true tokio.workspace = true tokio-eld = "0.2" diff --git a/ext/node/ops/os/mod.rs b/ext/node/ops/os/mod.rs index d45f67bd13..944f950607 100644 --- a/ext/node/ops/os/mod.rs +++ b/ext/node/ops/os/mod.rs @@ -4,6 +4,7 @@ use std::mem::MaybeUninit; use deno_core::op2; use deno_core::OpState; +use sys_traits::EnvHomeDir; use crate::NodePermissions; @@ -282,5 +283,9 @@ where permissions.check_sys("homedir", "node:os.homedir()")?; } - Ok(home::home_dir().map(|path| path.to_string_lossy().to_string())) + Ok( + sys_traits::impls::RealSys + .env_home_dir() + .map(|path| path.to_string_lossy().to_string()), + ) } diff --git a/runtime/permissions/lib.rs b/runtime/permissions/lib.rs index b36668b10c..8ab4058e79 100644 --- a/runtime/permissions/lib.rs +++ b/runtime/permissions/lib.rs @@ -1510,11 +1510,10 @@ impl AllowRunDescriptor { match which::which_in(text, std::env::var_os("PATH"), cwd) { Ok(path) => path, Err(err) => match err { - which::Error::BadAbsolutePath | which::Error::BadRelativePath => { + which::Error::CannotGetCurrentDirAndPathListEmpty => { return Err(err); } which::Error::CannotFindBinaryPath - | which::Error::CannotGetCurrentDir | which::Error::CannotCanonicalize => { return Ok(AllowRunDescriptorParseResult::Unresolved(Box::new(err))) }