diff --git a/Cargo.toml b/Cargo.toml index e2251a06e..fb8758264 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,7 +47,6 @@ either = "1.6.1" form_urlencoded = "1.2.0" futures = { version = "0.3.17", default-features = false } hashbrown = "0.16.0" -home = "0.5.4" hostname = "0.4" http = "1.1.0" http-body = "1.0.1" diff --git a/kube-client/Cargo.toml b/kube-client/Cargo.toml index 005ed4d61..be7e5c458 100644 --- a/kube-client/Cargo.toml +++ b/kube-client/Cargo.toml @@ -26,7 +26,7 @@ gzip = ["client", "tower-http/decompression-gzip"] client = ["config", "__non_core", "hyper", "hyper-util", "http-body", "http-body-util", "tower", "tower-http", "hyper-timeout", "chrono", "jsonpath-rust", "bytes", "futures", "tokio", "tokio-util", "either"] jsonpatch = ["kube-core/jsonpatch"] admission = ["kube-core/admission"] -config = ["__non_core", "pem", "home"] +config = ["__non_core", "pem"] socks5 = ["hyper-util/client-proxy"] http-proxy = ["hyper-util/client-proxy"] unstable-client = [] @@ -45,7 +45,6 @@ workspace = true [dependencies] base64 = { workspace = true, optional = true } chrono = { workspace = true, optional = true } -home = { workspace = true, optional = true } serde = { workspace = true, features = ["derive"] } serde_json.workspace = true serde_yaml = { workspace = true, optional = true } diff --git a/kube-client/src/config/file_config.rs b/kube-client/src/config/file_config.rs index af1ba688e..8a820f30e 100644 --- a/kube-client/src/config/file_config.rs +++ b/kube-client/src/config/file_config.rs @@ -660,7 +660,15 @@ fn ensure_trailing_newline(mut data: Vec) -> Vec { /// Returns kubeconfig path from `$HOME/.kube/config`. fn default_kube_path() -> Option { - home::home_dir().map(|h| h.join(".kube").join("config")) + // Before Rust 1.85.0, `home_dir` would return wrong results on Windows, usage of the crate + // `home` was encouraged (and is what kube-rs did). + // Rust 1.85.0 fixed the problem (https://doc.rust-lang.org/1.85.0/std/env/fn.home_dir.html), + // Rust 1.87.0 removed the function deprecation. + // As the MSRV was bumped to 1.85.0 we are safe to use the fixed std function. + // Note: We intentionally use `allow` over `expect` to support compilation on Rust >= 1.87.0 + // Note: This can be removed once the MSRV is bumped to >= 1.87.0 + #[allow(deprecated)] + std::env::home_dir().map(|h| h.join(".kube").join("config")) } mod base64serde {