{"record":{"id":"a06fe53b64dc2b87","repo":"dbt-labs/dbt-core","slug":"unable-to-get-home-directory","errorCode":null,"errorMessage":"Unable to get home directory","messagePattern":"Unable to get home directory","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-common/src/lease.rs","lineNumber":60,"sourceCode":"    }\n}\n\n/// Acquires a lease on the given directory and spawns a background renewal task.\n/// Returns a [`LeaseGuard`] that releases the lease when dropped.\n/// Uses default values for ttl and the renewal interval.\npub async fn acquire_lease(project_dir: &Path, relative_dir: &Path) -> FsResult<LeaseGuard> {\n    // default ttl and renewal\n    let lease_ttl: Duration = Duration::from_millis(2000);\n    let renewal_interval: Duration = Duration::from_millis(500);\n    acquire_lease_with_renewal(project_dir, relative_dir, lease_ttl, renewal_interval).await\n}\n\n/// Returns the lease file path for a given directory name:\n/// `~/.dbt/leases/.dbt_lease_{hash of <project_root>/<dir_name>/}`.\nfn lease_file_path(project_root: &Path, dir_name: &Path) -> PathBuf {\n    let dir_path = DbtPath::from(project_root.join(dir_name));\n\n    let home_dir = DbtPath::from(dirs::home_dir().expect(\"Unable to get home directory\"));\n    debug_assert!(home_dir.is_absolute());\n\n    let dbt_leases_dir = home_dir.join(\".dbt/leases\");\n    create_dir_all(&dbt_leases_dir).ok();\n\n    // Hash the directory that we are holding a lease on.\n    let mut hasher = Sha256::new();\n    hasher.update(dir_path.to_string_lossy().as_bytes());\n    let hash = hasher.finalize();\n    let hex = format!(\"{:x}\", hash);\n    let hash_string = hex[..10.min(hex.len())].to_string();\n\n    dbt_leases_dir\n        .join(format!(\".dbt_lease_{hash_string}\"))\n        .to_path_buf()\n}\n\nimpl LeaseHandler {","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-common/src/lease.rs#L42-L78","documentation":"Raised in lease_file_path while resolving where to write the dbt lease file: the user's home directory could not be determined from the environment (HOME/USERPROFILE unset or inaccessible via dirs), so the lease file path cannot be constructed.","triggerScenarios":"Thrown at crates/dbt-common/src/lease.rs:60 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set HOME (or the platform equivalent) in the environment","Run dbt from a context with a resolvable user home directory","Ensure the process is not running with an intentionally emptied environment"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}