Skip to content

Commit 49e6358

Browse files
authored
ssh-key: use std::env::home_dir instead of home crate (#415)
Prior to Rust 1.86, `std::env::home_dir` was deprecated in favor of the `home` crate. However, Rust 1.86 fixed the behavior of the function on Windows to use the `USERPROFILE` environment variable with a fallback to `GetUserProfileDirectory`, meaning we no longer need to use a crate for this purpose. Also, `home` now has an MSRV of 1.88, which would complicate our plans to launch with an MSRV of 1.85.
1 parent 7410bf7 commit 49e6358

3 files changed

Lines changed: 4 additions & 86 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 83 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ssh-key/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ dsa = { version = "0.7.0-rc.6", optional = true, default-features = false, featu
3232
ed25519-dalek = { version = "=3.0.0-pre.1", optional = true, default-features = false }
3333
hex = { version = "0.4", optional = true, default-features = false, features = ["alloc"] }
3434
hmac = { version = "0.13.0-rc.2", optional = true }
35-
home = { version = "0.5", optional = true }
3635
p256 = { version = "0.14.0-pre.11", optional = true, default-features = false, features = ["ecdsa"] }
3736
p384 = { version = "0.14.0-pre.11", optional = true, default-features = false, features = ["ecdsa"] }
3837
p521 = { version = "0.14.0-pre.11", optional = true, default-features = false, features = ["ecdsa"] }
@@ -49,7 +48,7 @@ rand_chacha = "0.9"
4948
[features]
5049
default = ["ecdsa", "rand_core", "std"]
5150
alloc = ["encoding/alloc", "signature/alloc", "zeroize/alloc", ]
52-
std = ["alloc", "dep:home"]
51+
std = ["alloc"]
5352

5453
crypto = ["ed25519", "p256", "p384", "p521", "rsa"] # NOTE: `dsa` is obsolete/weak
5554
dsa = ["dep:dsa", "dep:sha1", "alloc", "encoding/bigint", "signature/rand_core"]

ssh-key/src/dot_ssh.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
use crate::{Fingerprint, PrivateKey, PublicKey, Result};
44
use std::{
5+
env,
56
fs::{self, ReadDir},
67
path::{Path, PathBuf},
78
};
@@ -17,7 +18,8 @@ impl DotSsh {
1718
///
1819
/// Returns `None` if the home directory couldn't be located.
1920
pub fn new() -> Option<Self> {
20-
home::home_dir().map(|path| Self::open(path.join(".ssh")))
21+
#[allow(deprecated)] // NOTE: no longer deprecated as of Rust 1.86
22+
env::home_dir().map(|path| Self::open(path.join(".ssh")))
2123
}
2224

2325
/// Open a `~/.ssh`-structured directory.

0 commit comments

Comments
 (0)