dbt-labs / dbt-labs/dbt

[Bug] Error using dbtRunner with `profiles_dir` set and no `$HOME/.dbt` directory

Open
#11,286 1 comment 1 reaction 0 assignees View on GitHub
engine:v1 type:bug
Dominant language
Rust
Stars
13.8k
Forks
2.6k
Avg merge
21h 31m
Merged PRs (30d)
56

Description

### Is this a new bug in dbt-core?

- [x] I believe this is a new bug in dbt-core
- [x] I have searched the existing issues, and I could not find an existing issue for this bug

### Current Behavior

Error occurs even if profiles_dir is specified in kwargs on dbt cli when the home/.dbt directory does not exist.
But it worked when I specified --profiles-dir in the args or when I specified it in an environment variable.

I don't think this is the expected result.

### Expected Behavior

Even if home/.dbt does not exist, no error will occur if valid profiles_dir is specified.

### Steps To Reproduce

1. Delete home/.dbt.
2. Run the code below.
```python
DBT_DIR = "/path/to/dbt_dir"
res: dbtRunnerResult = dbt.invoke(
args=["ls"],
project_dir=DBT_DIR,
profiles_dir=DBT_DIR,
)
if res.success == False:
logger.error(f"Command failed with error: {res.exception}")
```
3. Error occured.
```
Command failed with error: Path '/Users/tnk-ysk/.dbt' does not exist.
```

### Relevant log output

```shell

```

### Environment

```markdown
- OS: macOS 14.4
- Python: 3.11.10
- dbt: 1.9.1
```

### Which database adapter are you using with dbt?

_No response_

### Additional Context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.