I could use some help troubleshooting the followin...
# ask-elementary-ai
s
I could use some help troubleshooting the following Airflow task error:
Copy code
elementary.exceptions.exceptions.DbtCommandError: Failed to run dbt command.
Runtime Error
  Could not find profile named 'elementary'
I’m running dbt commands within a Docker container that executes as an ECS task on AWS Fargate (triggered from Airflow). Inside my Dockerfile, I’ve set the environment variable:
Copy code
ENV DBT_PROFILES_DIR=/app/.dbt
My
profiles.yml
is valid and includes a proper
elementary
profile:
Copy code
elementary:
  outputs:
    default:
      type: redshift
      host: "{{ env_var('DB_HOST') }}"
      user: "{{ env_var('DB_USER') }}"
      password: "{{ env_var('DB_PASSWORD') }}"
      port: "{{ env_var('DB_PORT') | as_number }}"
      dbname: my_db
      schema: elementary
      threads: 4
      sslmode: verify-full
      ra3_node: true
These environment variables are confirmed to be set and available in the container before
edr monitor
runs.
k
A message from kapa.ai
s
Given that
DBT_PROFILES_DIR
is already set in the container, do I still need to explicitly pass a
--profiles-dir
flag (for example,
--profiles-dir /app
) to
edr monitor
for it to locate the
elementary
profile inside ECS?
k
Your error message:
Copy code
elementary.exceptions.exceptions.DbtCommandError: Failed to run dbt command. Runtime Error   Could not find profile named 'elementary'
is a common issue when the Elementary CLI (edr) cannot locate the
elementary
profile in your
profiles.yml
. Even if your
profiles.yml
is valid and the environment variable
DBT_PROFILES_DIR
is set, there are a few common pitfalls to check: 1. Location of `profiles.yml`: The path set in
DBT_PROFILES_DIR
should be the directory containing
profiles.yml
, not the file itself. For example, if your file is at
/app/.dbt/profiles.yml
, then
DBT_PROFILES_DIR
should be
/app/.dbt
(which you have set correctly). Double-check that the file is present at runtime and readable by the user running the command inside the container. This is a frequent source of issues, especially in Docker/ECS environments where file mounting or build context can be tricky [see here](https://slack.com/archives/C02CTC89LAX/p1688066687146099). 2. Profile Name: The profile name in your
profiles.yml
must be exactly
elementary
(case-sensitive), and the CLI will look for this key. Your example matches this requirement. 3. Permissions: Ensure that the user running the Airflow/ECS task has permission to read
/app/.dbt/profiles.yml
. Permission issues can sometimes manifest as "profile not found" errors. 4. Profile Target: If you have multiple outputs under
elementary
, make sure you specify the correct target with
--target
if it's not
default
. Otherwise, dbt will use
default
as the target [see here](https://slack.com/archives/C02CTC89LAX/p1680035534817339). 5. Environment Variables in Docker/ECS: Sometimes, environment variables (like
DB_HOST
,
DB_USER
, etc.) are not available to the process running dbt/edr if they're not set correctly in the ECS task definition or Dockerfile. Double-check that these are available at runtime. 6. Command Context: If you are running
edr
from a directory different from where your
profiles.yml
is, try explicitly passing the profiles directory:
Copy code
edr monitor --profiles-dir /app/.dbt
This has resolved similar issues for other users [see here](https://slack.com/archives/C02CTC89LAX/p1688066687146099). 7. File Content Validation: Make sure there are no YAML formatting issues or hidden characters in your
profiles.yml
. Even a small typo can cause dbt to not recognize the profile. Summary of what to try: - Confirm
/app/.dbt/profiles.yml
exists and is readable inside the running container. - Run
ls -l /app/.dbt
and
cat /app/.dbt/profiles.yml
inside the container to verify. - Try running
edr monitor --profiles-dir /app/.dbt
explicitly. - Double-check that the
elementary
key is at the top level of your YAML and is not indented or nested incorrectly. - Ensure all required environment variables are available to the process. If all of the above are correct and the error persists, there may be an issue with how the container is built or how the ECS task is mounting or copying files. This is a common scenario in containerized and orchestrated environments [see here](https://slack.com/archives/C02CTC89LAX/p1688066687146099), [and here](https://slack.com/archives/C02CTC89LAX/p1686013979045139). If you need further help, sharing the output of
ls -l /app/.dbt
and the exact command you are running inside the container can help pinpoint the issue.
s
@kapa.ai Within dbt, the parent directory for
profiles.yml
is determined using the following precedence: 1.
--profiles-dir
option 2.
DBT_PROFILES_DIR
environment variable 3. current working directory 4.
~/.dbt/
directory As I set the environmental variable
DBT_PROFILES_DIR
(precedence item #2), shouldn't EDR commands resolve the location as
profiles.yml
as
/app/.dbt
correctly? Or would I still need to explicitly pass this?
Copy code
edr monitor --profiles-dir /app/.dbt
k
A message from kapa.ai
Based on the knowledge sources, Elementary’s CLI (
edr
) supports specifying the profiles directory using the
--profiles-dir
option, and the documentation states that the default behavior is to look for
profiles.yml
in the following order: 1. The directory specified by
--profiles-dir
2. The current working directory 3.
HOME/.dbt/
directory However, the documentation and support threads do not explicitly confirm that the
DBT_PROFILES_DIR
environment variable is honored by
edr
in the same way as dbt itself. In fact, several support threads recommend explicitly passing
--profiles-dir
to avoid issues, especially in containerized or non-standard environments, even when environment variables are set [see here](https://slack.com/archives/C02CTC89LAX/p1669047039586539), [and here](https://slack.com/archives/C02CTC89LAX/p1667512333541799). Therefore, while dbt itself supports
DBT_PROFILES_DIR
, you may still need to explicitly pass
--profiles-dir /app/.dbt
to
edr
to ensure it finds your
profiles.yml
, particularly if you encounter issues. This is a recommended troubleshooting step and has resolved similar problems for other users. In summary: You may still need to explicitly pass
--profiles-dir /app/.dbt
to
edr
commands, even if you set
DBT_PROFILES_DIR
, to guarantee correct resolution of your
profiles.yml
location.
The knowledge sources do not confirm that
edr
always honors the environment variable as dbt does. If you want to be certain, use:
Copy code
edr monitor --profiles-dir /app/.dbt
to avoid ambiguity [see here](https://slack.com/archives/C02CTC89LAX/p1669047039586539).
s
@kapa.ai looking at Elementary documentation for the
--profiles-dir
option: • Profile directory path: The path of the directory in which your
profiles.yml
file is located. Default is
HOME_DIR/.dbt
. • This option must be configured together with profile name. • -p, --profiles-dir <PATH> Given the env var I have set above, how could I pass in that path using
--profiles-dir
with the
edr monitor
command?
k
A message from kapa.ai
To pass the path to your
profiles.yml
using the
--profiles-dir
option with the
edr monitor
command, you should specify the directory containing your
profiles.yml
file. For your setup, where
profiles.yml
is located at
/app/.dbt/profiles.yml
, the command would be:
Copy code
edr monitor --profiles-dir /app/.dbt
This tells Elementary to look for
profiles.yml
in
/app/.dbt
. According to the documentation, the
--profiles-dir
(or
-p
) option should be used to explicitly set the directory if it is not in the default location (
HOME_DIR/.dbt
) [CLI commands and usage](https://docs.elementary-data.com/oss/cli-commands#cli-options). The documentation does not mention support for the
DBT_PROFILES_DIR
environment variable, so using the
--profiles-dir
flag is the recommended and supported approach.
s
@kapa.ai Could I specify a path using Elementary's env var setup?
Copy code
You can define options either via the CLI or using environment variables in the following format: EDR_<COMMAND>_<OPTION>=<VALUE>.
The following example for
edr report
is given; I would like to apply something similar to `edr monitor`:
Copy code
export EDR_REPORT_FILE_PATH="my_report.html"
edr report
# Equivalent to: edr report --file-path "my_report.html"
k
A message from kapa.ai
Yes, you can specify a path using Elementary's environment variable setup for CLI options. According to the documentation, you can set CLI options via environment variables in the format:
Copy code
EDR_<COMMAND>_<OPTION>=<VALUE>
For the
edr monitor
command and the
--profiles-dir
option, you would set:
Copy code
export EDR_MONITOR_PROFILES_DIR="/app/.dbt" edr monitor
This is equivalent to running:
Copy code
edr monitor --profiles-dir /app/.dbt
This approach is documented and supported for all CLI options, including
--profiles-dir
 [CLI commands and usage](https://docs.elementary-data.com/oss/cli-commands#cli-options).