Don't use $HOME env variable because it doesn't always work

This commit is contained in:
southerntofu 2021-01-04 15:30:34 +01:00
parent ec10c2f6bd
commit 741af8c6f1
3 changed files with 14 additions and 1 deletions

10
Cargo.lock generated
View File

@ -46,6 +46,7 @@ name = "forgebuild"
version = "0.2.0"
dependencies = [
"glob",
"home",
"hostname",
"lazy_static",
"serde",
@ -77,6 +78,15 @@ dependencies = [
"libc",
]
[[package]]
name = "home"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2456aef2e6b6a9784192ae780c0f15bc57df0e918585282325e8c8ac27737654"
dependencies = [
"winapi",
]
[[package]]
name = "hostname"
version = "0.3.1"

View File

@ -16,3 +16,5 @@ serde_json = "1.0"
structopt = "0.3"
# Debug Context for translations
serde = { version = "1.0", features = ["derive"] }
# Detect home folder
home = "0.5.3"

View File

@ -1,6 +1,7 @@
use std::env;
use std::path::PathBuf;
use structopt::StructOpt;
use home::home_dir;
#[derive(Debug, StructOpt)]
#[structopt(
@ -26,7 +27,7 @@ impl Cli {
// Returns an error when the path doesn't exist
PathBuf::from(basedir)
} else {
let mut home_path = PathBuf::from(env::var("HOME").expect("No $HOME in env"));
let mut home_path = home_dir().expect("No HOME folder found.");
home_path.push(".forgebuild");
home_path
}