sqlfluff dbt templater error in CI
sqlfluff was configured with templater = dbt but could not render the models: the sqlfluff-templater-dbt plugin is missing, dbt packages were not installed, or the profile/connection is unavailable in CI.
What this error means
A sqlfluff lint step with the dbt templater fails to compile models, reporting a missing dbt templater plugin, a profile error, or an unresolved ref.
User Error: Failed to import dbt templater. Please ensure sqlfluff-templater-dbt
is installed. ModuleNotFoundError: No module named 'dbt'Common causes
The dbt templater plugin is not installed
templater = dbt requires the separate sqlfluff-templater-dbt package plus a dbt adapter; without them sqlfluff cannot render models.
dbt deps or the profile are missing in CI
The templater compiles via dbt, so it needs dbt deps run and a valid profiles.yml/connection, which may be absent in the lint job.
How to fix it
Install the templater and prepare dbt
- Install
sqlfluff-templater-dbtand your dbt adapter. - Run
dbt depsso package macros resolve. - Provide a
profiles.yml(credentials from secrets) so compilation succeeds.
python -m pip install sqlfluff sqlfluff-templater-dbt dbt-postgres
dbt deps
sqlfluff lint models/ --dialect postgresUse the jinja templater to avoid a live connection
If you do not want dbt compilation in the lint job, use templater = jinja with a static context so no warehouse connection is needed.
[sqlfluff]
templater = jinja
dialect = postgresHow to prevent it
- Install
sqlfluff-templater-dbtand the adapter together. - Run
dbt depsbefore linting with the dbt templater. - Prefer the jinja templater when a live warehouse is not available in CI.