How to set project-dir in dbt with environment variable?

Viewed 2040

I am trying to locate my dbt_project.yml file which is not in the root directory of my project. Previously, I was using an env var called DBT_PROJECT_DIR in order to define where dbt_project.yml file is located and it was working fine. In a similar way, I am using DBT_PROFILE_DIR and it still works correct. But I cannot make DBT_PROJECT_DIR work. Any help is appreciated.

2 Answers

I'm fairly certain this is not supported. Are you not able to change the directory to the directory of the dbt_project.yml before running dbt commands?

As a workaround, could you just add --project-dir $PROJECT_DIR to every command you plan to run?

It is indeed not supported, this get_nearest_project_dir function is used to find the project dir. That should be adjusted to allow for using a environment variable, similar to profiles indeed.

You could open an issue on Github, discuss adding this feature there.

Related