MetricSign
EN|NLRequest Access
High severityconfiguration

Power BI Refresh Error:
EnvironmentVariableNotSet

What does this error mean?

A dbt model, macro, or profile references an environment variable using env_var() that was not set in the dbt Cloud environment configuration, causing a compilation or runtime error.

Common causes

  • 1The environment variable was set in the development environment but not in the production or staging environment
  • 2A new model or macro was added that references an env_var() not yet configured in dbt Cloud
  • 3The variable name in the code has a typo compared to the name configured in dbt Cloud
  • 4The dbt Cloud environment was cloned from another project but environment variables were not copied

How to fix it

  1. 1Step 1: Read the error message — dbt names the exact environment variable that is missing.
  2. 2Step 2: In dbt Cloud, go to Deploy > Environments > the relevant environment > Environment Variables and add the missing variable.
  3. 3Step 3: If the variable is optional, provide a default in the code using env_var('MY_VAR', 'default_value').
  4. 4Step 4: Verify the variable name matches exactly, including case — dbt environment variable names are case-sensitive.
  5. 5Step 5: Re-run the job after adding the variable to confirm compilation succeeds.

Frequently asked questions

Are dbt Cloud environment variables available at both compile time and run time?

Yes. Variables set using env_var() are resolved at compile time when dbt renders Jinja. They are also available in run-time contexts like dbt hooks and macros that execute SQL.

How do I set environment variables for dbt Core (not dbt Cloud)?

For dbt Core, set environment variables in the shell before running dbt commands (e.g., export MY_VAR=value) or in your CI/CD pipeline's environment configuration. In dbt profiles.yml, reference them with '{{ env_var("MY_VAR") }}'.

Other configuration errors