From 1b7e2639db157d6a123b1456e0587ed6d8cd3c5a Mon Sep 17 00:00:00 2001 From: Lucio Franco Date: Wed, 21 Sep 2022 10:11:40 -0400 Subject: [PATCH 1/3] Update home usage to new env fn --- src/currentprocess.rs | 4 ++-- src/currentprocess/homethunk.rs | 16 ++++++++-------- src/utils/utils.rs | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/currentprocess.rs b/src/currentprocess.rs index f4cea4b9bc..2bcaa0ce14 100644 --- a/src/currentprocess.rs +++ b/src/currentprocess.rs @@ -55,7 +55,7 @@ use varsource::*; /// The real trait is CurrentProcess; HomeProcess is a single trait because /// Box only allows autotraits to be added to it; so we use a subtrait to add /// home::Env in. -pub trait HomeProcess: CurrentProcess + home::Env { +pub trait HomeProcess: CurrentProcess + home::env::Env { fn clone_boxed(&self) -> Box; } @@ -63,7 +63,7 @@ pub trait HomeProcess: CurrentProcess + home::Env { impl HomeProcess for T where - T: 'static + CurrentProcess + home::Env + Clone, + T: 'static + CurrentProcess + home::env::Env + Clone, { fn clone_boxed(&self) -> Box { Box::new(T::clone(self)) diff --git a/src/currentprocess/homethunk.rs b/src/currentprocess/homethunk.rs index 36077e31c5..5314afec66 100644 --- a/src/currentprocess/homethunk.rs +++ b/src/currentprocess/homethunk.rs @@ -10,19 +10,19 @@ use super::OSProcess; use super::TestProcess; use super::VarSource; -impl home::Env for Box { +impl home::env::Env for Box { fn home_dir(&self) -> Option { (**self).home_dir() } fn current_dir(&self) -> Result { - home::Env::current_dir(&(**self)) + home::env::Env::current_dir(&(**self)) } fn var_os(&self, key: &str) -> Option { - home::Env::var_os(&(**self), key) + home::env::Env::var_os(&(**self), key) } } -impl home::Env for TestProcess { +impl home::env::Env for TestProcess { fn home_dir(&self) -> Option { self.var("HOME").ok().map(|v| v.into()) } @@ -34,14 +34,14 @@ impl home::Env for TestProcess { } } -impl home::Env for OSProcess { +impl home::env::Env for OSProcess { fn home_dir(&self) -> Option { - home::OS_ENV.home_dir() + home::env::OS_ENV.home_dir() } fn current_dir(&self) -> Result { - home::OS_ENV.current_dir() + home::env::OS_ENV.current_dir() } fn var_os(&self, key: &str) -> Option { - home::OS_ENV.var_os(key) + home::env::OS_ENV.var_os(key) } } diff --git a/src/utils/utils.rs b/src/utils/utils.rs index 0362372b5e..d6e031a8f2 100644 --- a/src/utils/utils.rs +++ b/src/utils/utils.rs @@ -493,11 +493,11 @@ pub(crate) fn to_absolute>(path: P) -> Result { } pub(crate) fn home_dir() -> Option { - home::home_dir_from(&home_process()) + home::env::home_dir_with_env(&home_process()) } pub(crate) fn cargo_home() -> Result { - home::cargo_home_from(&home_process()).context("failed to determine cargo home") + home::env::cargo_home_with_env(&home_process()).context("failed to determine cargo home") } // Creates a ~/.rustup folder @@ -524,7 +524,7 @@ fn rustup_home_in_user_dir() -> Result { } pub(crate) fn rustup_home() -> Result { - home::rustup_home_from(&home_process()).context("failed to determine rustup home dir") + home::env::rustup_home_with_env(&home_process()).context("failed to determine rustup home dir") } pub(crate) fn format_path_for_display(path: &str) -> String { From 53b31bc0c0642b077a4bf3f8f3847a156fb34c64 Mon Sep 17 00:00:00 2001 From: Lucio Franco Date: Thu, 22 Sep 2022 10:42:20 -0400 Subject: [PATCH 2/3] Update code to use `home::env as home` as suggested --- src/currentprocess.rs | 5 +++-- src/currentprocess/homethunk.rs | 18 ++++++++++-------- src/utils/utils.rs | 7 ++++--- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/currentprocess.rs b/src/currentprocess.rs index 2bcaa0ce14..392824b0a1 100644 --- a/src/currentprocess.rs +++ b/src/currentprocess.rs @@ -9,6 +9,7 @@ use std::path::{Path, PathBuf}; use std::sync::Once; use std::sync::{Arc, Mutex}; +use home::env as home; use rand::{thread_rng, Rng}; pub(crate) mod argsource; @@ -55,7 +56,7 @@ use varsource::*; /// The real trait is CurrentProcess; HomeProcess is a single trait because /// Box only allows autotraits to be added to it; so we use a subtrait to add /// home::Env in. -pub trait HomeProcess: CurrentProcess + home::env::Env { +pub trait HomeProcess: CurrentProcess + home::Env { fn clone_boxed(&self) -> Box; } @@ -63,7 +64,7 @@ pub trait HomeProcess: CurrentProcess + home::env::Env { impl HomeProcess for T where - T: 'static + CurrentProcess + home::env::Env + Clone, + T: 'static + CurrentProcess + home::Env + Clone, { fn clone_boxed(&self) -> Box { Box::new(T::clone(self)) diff --git a/src/currentprocess/homethunk.rs b/src/currentprocess/homethunk.rs index 5314afec66..1c065d0992 100644 --- a/src/currentprocess/homethunk.rs +++ b/src/currentprocess/homethunk.rs @@ -4,25 +4,27 @@ use std::io; use std::ops::Deref; use std::path::PathBuf; +use home::env as home; + use super::CurrentDirSource; use super::HomeProcess; use super::OSProcess; use super::TestProcess; use super::VarSource; -impl home::env::Env for Box { +impl home::Env for Box { fn home_dir(&self) -> Option { (**self).home_dir() } fn current_dir(&self) -> Result { - home::env::Env::current_dir(&(**self)) + home::Env::current_dir(&(**self)) } fn var_os(&self, key: &str) -> Option { - home::env::Env::var_os(&(**self), key) + home::Env::var_os(&(**self), key) } } -impl home::env::Env for TestProcess { +impl home::Env for TestProcess { fn home_dir(&self) -> Option { self.var("HOME").ok().map(|v| v.into()) } @@ -34,14 +36,14 @@ impl home::env::Env for TestProcess { } } -impl home::env::Env for OSProcess { +impl home::Env for OSProcess { fn home_dir(&self) -> Option { - home::env::OS_ENV.home_dir() + home::OS_ENV.home_dir() } fn current_dir(&self) -> Result { - home::env::OS_ENV.current_dir() + home::OS_ENV.current_dir() } fn var_os(&self, key: &str) -> Option { - home::env::OS_ENV.var_os(key) + home::OS_ENV.var_os(key) } } diff --git a/src/utils/utils.rs b/src/utils/utils.rs index d6e031a8f2..873284db41 100644 --- a/src/utils/utils.rs +++ b/src/utils/utils.rs @@ -5,6 +5,7 @@ use std::io::{self, BufReader, Write}; use std::path::{Path, PathBuf}; use anyhow::{anyhow, bail, Context, Result}; +use home::env as home; use retry::delay::{jitter, Fibonacci}; use retry::{retry, OperationResult}; use sha2::Sha256; @@ -493,11 +494,11 @@ pub(crate) fn to_absolute>(path: P) -> Result { } pub(crate) fn home_dir() -> Option { - home::env::home_dir_with_env(&home_process()) + home::home_dir_with_env(&home_process()) } pub(crate) fn cargo_home() -> Result { - home::env::cargo_home_with_env(&home_process()).context("failed to determine cargo home") + home::cargo_home_with_env(&home_process()).context("failed to determine cargo home") } // Creates a ~/.rustup folder @@ -524,7 +525,7 @@ fn rustup_home_in_user_dir() -> Result { } pub(crate) fn rustup_home() -> Result { - home::env::rustup_home_with_env(&home_process()).context("failed to determine rustup home dir") + home::rustup_home_with_env(&home_process()).context("failed to determine rustup home dir") } pub(crate) fn format_path_for_display(path: &str) -> String { From f7845522a8f0c5d251e5ec44bec8faf665b0b7cf Mon Sep 17 00:00:00 2001 From: Lucio Franco Date: Tue, 11 Oct 2022 10:11:08 -0400 Subject: [PATCH 3/3] Update to home 0.5.4 --- Cargo.lock | 5 +++-- Cargo.toml | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5242917c02..de22dca507 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -974,8 +974,9 @@ dependencies = [ [[package]] name = "home" -version = "0.5.3" -source = "git+https://github.com/rbtcollins/home?rev=a243ee2fbee6022c57d56f5aa79aefe194eabe53#a243ee2fbee6022c57d56f5aa79aefe194eabe53" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "747309b4b440c06d57b0b25f2aee03ee9b5e5397d288c60e21fc709bb98a7408" dependencies = [ "winapi", ] diff --git a/Cargo.toml b/Cargo.toml index 92de5b2882..65a22ce982 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ effective-limits = "0.5.3" enum-map = "2.0.3" flate2 = "1" git-testament = "0.2" -home = {git = "https://github.com/rbtcollins/home", rev = "a243ee2fbee6022c57d56f5aa79aefe194eabe53"} +home = "0.5.4" lazy_static = "1" libc = "0.2" num_cpus = "1.13" @@ -127,3 +127,4 @@ lto = true # Reduce build time by setting proc-macro crates non optimized. [profile.release.build-override] opt-level = 0 +