diff --git a/Cargo.lock b/Cargo.lock index db68584..ca60d0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -370,6 +370,27 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys", +] + [[package]] name = "either" version = "1.9.0" @@ -565,6 +586,7 @@ dependencies = [ "clap", "clap-verbosity-flag", "derive_more", + "dirs", "futures-util", "golem-client", "golem-examples", @@ -1013,6 +1035,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "parking_lot" version = "0.12.1" @@ -1031,7 +1059,7 @@ checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.3.5", "smallvec", "windows-targets", ] @@ -1114,6 +1142,15 @@ dependencies = [ "getrandom", ] +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "redox_syscall" version = "0.3.5" @@ -1123,6 +1160,17 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom", + "redox_syscall 0.2.16", + "thiserror", +] + [[package]] name = "regex" version = "1.9.5" @@ -1443,7 +1491,7 @@ checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", + "redox_syscall 0.3.5", "rustix", "windows-sys", ] diff --git a/Cargo.toml b/Cargo.toml index 56da801..bba3a5c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,3 +35,4 @@ tracing = "0.1.37" tungstenite = "0.20.0" url = "2.4.1" uuid = "1.4.1" +dirs = "5.0.1" diff --git a/src/main.rs b/src/main.rs index 7717852..b815935 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,6 +17,7 @@ use golem_examples::model::{ExampleName, GuestLanguage, GuestLanguageTier, Packa use model::*; use reqwest::Url; use serde::Serialize; +use tracing::debug; use uuid::Uuid; use crate::account::{AccountHandler, AccountHandlerLive, AccountSubcommand}; @@ -244,10 +245,15 @@ async fn async_main(cmd: GolemCommand) -> Result<(), Box> let url_str = std::env::var("GOLEM_BASE_URL").unwrap_or("https://release.api.golem.cloud/".to_string()); let url = Url::parse(&url_str).unwrap(); - let home = std::env::var("HOME").unwrap(); + let home = dirs::home_dir().unwrap(); let allow_insecure_str = std::env::var("GOLEM_ALLOW_INSECURE").unwrap_or("false".to_string()); let allow_insecure = allow_insecure_str != "false"; - let default_conf_dir = PathBuf::from(format!("{home}/.golem")); + let default_conf_dir = home.join(".golem"); + + debug!( + "Golem configuration directory: {}", + default_conf_dir.display() + ); let login = LoginClientLive { login: golem_client::login::LoginLive {