From 4fabe801d73481cf6d53b1751ffeb8da21321068 Mon Sep 17 00:00:00 2001 From: John Edmonds Date: Tue, 9 Sep 2025 11:25:37 -0400 Subject: [PATCH 1/5] Find the right home directory for Windows. --- crates/dbt-init/src/init.rs | 15 +++++++-------- crates/dbt-init/src/profile_setup.rs | 8 ++++---- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/crates/dbt-init/src/init.rs b/crates/dbt-init/src/init.rs index e1425738..7b0d21e9 100644 --- a/crates/dbt-init/src/init.rs +++ b/crates/dbt-init/src/init.rs @@ -7,7 +7,7 @@ use dbt_common::{ErrorCode, FsResult, fs_err}; use rust_embed::RustEmbed; use std::env; use std::fs; -use std::path::Path; +use std::path::{Path, PathBuf}; #[derive(RustEmbed)] #[folder = "assets/jaffle_shop/"] @@ -127,12 +127,11 @@ pub fn init_project(project_name: &str, target_dir: &Path) -> FsResult<()> { Ok(()) } -pub fn get_profiles_dir() -> String { +pub fn get_profiles_dir() -> PathBuf { // Try environment variable first, then fall back to default - env::var("DBT_PROFILES_DIR").unwrap_or_else(|_| { - let home = env::var("HOME").unwrap_or_else(|_| ".".to_string()); - format!("{home}/.dbt") - }) + env::var("DBT_PROFILES_DIR") + .map(PathBuf::from) + .unwrap_or_else(|_| env::home_dir().unwrap_or_else(|| ".".into()).join(".dbt")) } /// Check if we're currently in a dbt project directory @@ -231,8 +230,8 @@ fn update_dbt_project_profile(profile_name: &str) -> FsResult<()> { } /// Check if a profile exists in profiles.yml -pub fn check_if_profile_exists(profile_name: &str, profiles_dir: &str) -> FsResult { - let profiles_file = Path::new(profiles_dir).join("profiles.yml"); +pub fn check_if_profile_exists(profile_name: &str, profiles_dir: &PathBuf) -> FsResult { + let profiles_file = profiles_dir.join("profiles.yml"); if !profiles_file.exists() { return Ok(false); } diff --git a/crates/dbt-init/src/profile_setup.rs b/crates/dbt-init/src/profile_setup.rs index 06b508f7..b2a61a3c 100644 --- a/crates/dbt-init/src/profile_setup.rs +++ b/crates/dbt-init/src/profile_setup.rs @@ -30,7 +30,7 @@ pub type Profiles = HashMap; /// Load profile using the standard dbt-loader infrastructure fn load_profile_with_loader( - profiles_dir: Option<&str>, + profiles_dir: Option<&PathBuf>, profile_name: &str, target: Option<&str>, ) -> FsResult { @@ -129,18 +129,18 @@ impl ProjectStore { format!("https://{}", self.config.context.active_host) } - pub fn try_load_profile(&self, profiles_dir: &str, profile_name: &str) -> Option { + pub fn try_load_profile(&self, profiles_dir: &PathBuf, profile_name: &str) -> Option { load_profile_with_loader(Some(profiles_dir), profile_name, None).ok() } } pub struct ProfileSetup { - pub profiles_dir: String, + pub profiles_dir: PathBuf, pub project_store: Option, } impl ProfileSetup { - pub fn new(profiles_dir: String) -> Self { + pub fn new(profiles_dir: PathBuf) -> Self { let project_store = ProjectStore::from_dbt_cloud_yml().unwrap_or(None); Self { profiles_dir, From ab7f63036f1ba92b26d8fc1f56a0250e87234320 Mon Sep 17 00:00:00 2001 From: John Edmonds Date: Tue, 9 Sep 2025 11:53:17 -0400 Subject: [PATCH 2/5] Add changelog entry. --- .changes/unreleased/Fixes-20250909-115226.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changes/unreleased/Fixes-20250909-115226.yaml diff --git a/.changes/unreleased/Fixes-20250909-115226.yaml b/.changes/unreleased/Fixes-20250909-115226.yaml new file mode 100644 index 00000000..d6cfcd26 --- /dev/null +++ b/.changes/unreleased/Fixes-20250909-115226.yaml @@ -0,0 +1,7 @@ +kind: Fixes +body: Use the correct home directory on Windows. +time: 2025-09-09T11:52:26.2001804-04:00 +custom: + author: johnedmonds + issue: "" + project: dbt-fusion From e3de7bcbd669986ea7906fd8c61e7cec7609dfb8 Mon Sep 17 00:00:00 2001 From: John Edmonds Date: Thu, 11 Sep 2025 12:02:41 -0400 Subject: [PATCH 3/5] Update crates/dbt-init/src/init.rs Co-authored-by: Bo Lin --- crates/dbt-init/src/init.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/dbt-init/src/init.rs b/crates/dbt-init/src/init.rs index 7b0d21e9..9789a5a7 100644 --- a/crates/dbt-init/src/init.rs +++ b/crates/dbt-init/src/init.rs @@ -230,7 +230,7 @@ fn update_dbt_project_profile(profile_name: &str) -> FsResult<()> { } /// Check if a profile exists in profiles.yml -pub fn check_if_profile_exists(profile_name: &str, profiles_dir: &PathBuf) -> FsResult { +pub fn check_if_profile_exists(profile_name: &str, profiles_dir: &Path) -> FsResult { let profiles_file = profiles_dir.join("profiles.yml"); if !profiles_file.exists() { return Ok(false); From 5848da84e40c5c04db1c4a0ffe93a5fe45c7552d Mon Sep 17 00:00:00 2001 From: John Edmonds Date: Thu, 11 Sep 2025 12:02:45 -0400 Subject: [PATCH 4/5] Update crates/dbt-init/src/profile_setup.rs Co-authored-by: Bo Lin --- crates/dbt-init/src/profile_setup.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/dbt-init/src/profile_setup.rs b/crates/dbt-init/src/profile_setup.rs index b2a61a3c..32eccafa 100644 --- a/crates/dbt-init/src/profile_setup.rs +++ b/crates/dbt-init/src/profile_setup.rs @@ -30,7 +30,7 @@ pub type Profiles = HashMap; /// Load profile using the standard dbt-loader infrastructure fn load_profile_with_loader( - profiles_dir: Option<&PathBuf>, + profiles_dir: Option<&Path>, profile_name: &str, target: Option<&str>, ) -> FsResult { From 1604a744cec9b1643c37ca07eee1d4c3b8f113d1 Mon Sep 17 00:00:00 2001 From: John Edmonds Date: Thu, 11 Sep 2025 12:02:52 -0400 Subject: [PATCH 5/5] Update crates/dbt-init/src/profile_setup.rs Co-authored-by: Bo Lin --- crates/dbt-init/src/profile_setup.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/dbt-init/src/profile_setup.rs b/crates/dbt-init/src/profile_setup.rs index 32eccafa..e1cf3ca9 100644 --- a/crates/dbt-init/src/profile_setup.rs +++ b/crates/dbt-init/src/profile_setup.rs @@ -129,7 +129,7 @@ impl ProjectStore { format!("https://{}", self.config.context.active_host) } - pub fn try_load_profile(&self, profiles_dir: &PathBuf, profile_name: &str) -> Option { + pub fn try_load_profile(&self, profiles_dir: &Path, profile_name: &str) -> Option { load_profile_with_loader(Some(profiles_dir), profile_name, None).ok() } }