Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changes/unreleased/Fixes-20250909-115226.yaml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 7 additions & 8 deletions crates/dbt-init/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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/"]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<bool> {
let profiles_file = Path::new(profiles_dir).join("profiles.yml");
pub fn check_if_profile_exists(profile_name: &str, profiles_dir: &Path) -> FsResult<bool> {
let profiles_file = profiles_dir.join("profiles.yml");
if !profiles_file.exists() {
return Ok(false);
}
Expand Down
8 changes: 4 additions & 4 deletions crates/dbt-init/src/profile_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub type Profiles = HashMap<String, ProfileTarget>;

/// Load profile using the standard dbt-loader infrastructure
fn load_profile_with_loader(
profiles_dir: Option<&str>,
profiles_dir: Option<&Path>,
profile_name: &str,
target: Option<&str>,
) -> FsResult<DbConfig> {
Expand Down Expand Up @@ -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<DbConfig> {
pub fn try_load_profile(&self, profiles_dir: &Path, profile_name: &str) -> Option<DbConfig> {
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<ProjectStore>,
}

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,
Expand Down