Skip to content

Commit b7ce487

Browse files
authored
Remove Home Crate Dependency (#667)
1 parent b72646c commit b7ce487

5 files changed

Lines changed: 8 additions & 8 deletions

File tree

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ digest = "0.10"
1111
delegate = "0.13"
1212
env_logger = "0.6"
1313
futures = "0.3"
14-
home = "0.5"
1514
hmac = "0.12"
1615
log = "0.4.11"
1716
rand = { version = "0.9", features = ["thread_rng"] }

russh-config/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ version = "0.57.0"
1111
rust-version = "1.85"
1212

1313
[dependencies]
14-
home.workspace = true
1514
futures.workspace = true
1615
globset = "0.4"
1716
log.workspace = true

russh-config/src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
clippy::indexing_slicing,
55
clippy::panic
66
)]
7+
use std::env;
78
use std::io::Read;
89
use std::path::{Path, PathBuf};
910

@@ -320,7 +321,7 @@ pub fn parse(file: &str, host: &str) -> Result<Config, Error> {
320321
}
321322

322323
pub fn parse_home(host: &str) -> Result<Config, Error> {
323-
let mut home = if let Some(home) = home::home_dir() {
324+
let mut home = if let Some(home) = env::home_dir() {
324325
home
325326
} else {
326327
return Err(Error::NoHome);
@@ -373,7 +374,7 @@ impl SshConfigStrExt for &str {
373374

374375
fn expand_home(&self) -> Result<PathBuf, Error> {
375376
if self.starts_with("~/") {
376-
if let Some(mut home) = home::home_dir() {
377+
if let Some(mut home) = env::home_dir() {
377378
home.push(self.split_at(2).1);
378379
Ok(home)
379380
} else {
@@ -388,6 +389,7 @@ impl SshConfigStrExt for &str {
388389
#[cfg(test)]
389390
mod tests {
390391
#![allow(clippy::expect_used)]
392+
use std::env;
391393
use std::path::{Path, PathBuf};
392394

393395
use crate::{AddKeysToAgent, Config, Error, SshConfigStrExt, parse};
@@ -420,7 +422,7 @@ mod tests {
420422
assert_eq!(
421423
format!(
422424
"{}{}",
423-
home::home_dir().expect("homedir").to_str().expect("to_str"),
425+
env::home_dir().expect("homedir").to_str().expect("to_str"),
424426
"/some/folder"
425427
),
426428
value.to_str().unwrap()
@@ -455,7 +457,7 @@ Host test_host
455457
#";
456458
let identity_file = PathBuf::from(format!(
457459
"{}{}",
458-
home::home_dir().expect("homedir").to_str().expect("to_str"),
460+
env::home_dir().expect("homedir").to_str().expect("to_str"),
459461
"/.ssh/id_ed25519"
460462
));
461463
let config = parse(value, "test_host").expect("parse");

russh/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ tokio = { workspace = true, features = [
9999
"time",
100100
"net",
101101
] }
102-
home.workspace = true
103102

104103
[target.'cfg(windows)'.dependencies]
105104
pageant = { version = "0.2", path = "../pageant" }

russh/src/keys/known_hosts.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::borrow::Cow;
22
use std::fs::{File, OpenOptions};
33
use std::io::{BufRead, BufReader, Read, Seek, SeekFrom, Write};
44
use std::path::{Path, PathBuf};
5+
use std::env;
56

67
use data_encoding::BASE64_MIME;
78
use hmac::{Hmac, Mac};
@@ -48,7 +49,7 @@ pub fn check_known_hosts_path<P: AsRef<Path>>(
4849
}
4950

5051
fn known_hosts_path() -> Result<PathBuf, Error> {
51-
home::home_dir()
52+
env::home_dir()
5253
.map(|home_dir| home_dir.join(".ssh").join("known_hosts"))
5354
.ok_or(Error::NoHomeDir)
5455
}

0 commit comments

Comments
 (0)