Skip to content
Latchkey

dbt Compilation Error: model depends on a node not found (ref) in CI

dbt built the dependency graph and a ref() pointed at a model name it cannot find. Either the referenced model file is missing, renamed, or misspelled, or it lives in a package that was not installed.

What this error means

dbt compile, run, or build stops with "Compilation Error: Model 'X' depends on a node named 'Y' which was not found".

dbt
Compilation Error
  Model 'model.my_project.orders' (models/marts/orders.sql) depends on a node
  named 'stg_orders' which was not found

Common causes

The referenced model name is misspelled or renamed

A ref('stg_orders') points at a name that no model produces because the file was renamed or the string is wrong.

The referenced model comes from an uninstalled package

The model lives in a dbt package that dbt deps did not install, so the node is absent from the graph.

How to fix it

Correct the ref or add the missing model

  1. Confirm a model file produces the exact name used in ref().
  2. Fix the string or restore the renamed model.
  3. Run dbt compile to confirm the graph resolves.
Terminal
dbt compile --select orders

Install packages that provide referenced models

If the model comes from a package, run dbt deps before compiling so its nodes exist.

Terminal
dbt deps
dbt compile

How to prevent it

  • Run dbt deps before compile so package models are present.
  • Use ref() names that exactly match model file outputs.
  • Run dbt compile in CI on every change to catch broken refs early.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →