refactor: replace home dependency with std::env::home_dir
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -2988,7 +2988,6 @@ dependencies = [
|
||||
"futures",
|
||||
"glob",
|
||||
"globset",
|
||||
"home",
|
||||
"ignore",
|
||||
"indexmap",
|
||||
"is_elevated",
|
||||
|
||||
@@ -14,7 +14,6 @@ edition = "2021"
|
||||
readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
home = "=0.5.11"
|
||||
etcetera = "=0.10.0"
|
||||
serde = { version = "~1.0", features = ["derive"] }
|
||||
toml = { version = "=0.9.8", features = ["preserve_order"] }
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#![allow(clippy::cognitive_complexity)]
|
||||
|
||||
use std::env;
|
||||
use std::env::home_dir;
|
||||
use std::io;
|
||||
use std::path::PathBuf;
|
||||
use std::process::exit;
|
||||
@@ -48,7 +49,7 @@ mod sudo;
|
||||
mod terminal;
|
||||
mod utils;
|
||||
|
||||
pub(crate) static HOME_DIR: LazyLock<PathBuf> = LazyLock::new(|| home::home_dir().expect("No home directory"));
|
||||
pub(crate) static HOME_DIR: LazyLock<PathBuf> = LazyLock::new(|| home_dir().expect("No home directory"));
|
||||
#[cfg(unix)]
|
||||
pub(crate) static XDG_DIRS: LazyLock<Xdg> = LazyLock::new(|| Xdg::new().expect("No home directory"));
|
||||
|
||||
|
||||
@@ -2,13 +2,13 @@ use color_eyre::eyre::Context;
|
||||
use color_eyre::eyre::Result;
|
||||
use color_eyre::eyre::{eyre, OptionExt};
|
||||
use etcetera::BaseStrategy;
|
||||
use home;
|
||||
use ini::Ini;
|
||||
#[cfg(target_os = "linux")]
|
||||
use nix::unistd::Uid;
|
||||
use regex::Regex;
|
||||
use rust_i18n::t;
|
||||
use semver::Version;
|
||||
use std::env::home_dir;
|
||||
use std::ffi::OsStr;
|
||||
use std::io::Write;
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
@@ -526,8 +526,8 @@ pub fn run_nix(ctx: &ExecutionContext) -> Result<()> {
|
||||
let nix = require("nix")?;
|
||||
let nix_channel = require("nix-channel")?;
|
||||
let nix_env = require("nix-env")?;
|
||||
// TODO: Is None possible here?
|
||||
let profile_path = match home::home_dir() {
|
||||
// TODO: Is None possible here? Should we use HOME_DIR instead?
|
||||
let profile_path = match home_dir() {
|
||||
Some(home) => XDG_DIRS
|
||||
.state_dir()
|
||||
.map(|d| d.join("nix/profile"))
|
||||
|
||||
Reference in New Issue
Block a user