## TL;DR

Two models share a name, usually after a copy-paste or a staging/prod folder split. Rename one, or disable the one you dont need with enabled: false in its config. Then dbt ls to confirm each name resolves to exactly one node.

## Error

```text
dbt AmbiguousAliasError: duplicate model name in project
```

## Steps

1. Run dbt ls --resource-type model and grep for the duplicated name to find both files.
   Expected: Two file paths show up for the same model name, e.g. models/staging/stg_orders.sql and models/marts/stg_orders.sql.

2. Decide which one is canonical. Rename the other file and its references, or add {{ config(enabled=false) }} to the top of the one you want to keep out of the DAG.
   Expected: Only one enabled model carries the name.

3. Search the project for ref('old_name') calls that pointed at the renamed or disabled model and update them.
   Expected: No refs point at the old name; grep for it returns nothing.

4. Run dbt ls again and then dbt compile for the full project.
   Expected: Each model name appears once, compile succeeds with no AmbiguousAliasError.

## When to use

- dbt raises AmbiguousAliasError or found two resources with the same name
- you duplicated a model file to try a variant and forgot to rename it
- a merge brought in a second model with the same name

## When not to use

- duplicate column names inside a single model's select (that is a SQL error, not this)
- two models with similar but different names
- the error is about sources or seeds, which have their own dedupe rules

## Tool compatibility

- dbt-core all versions; node naming rules unchanged
- dbt ls is the fastest way to list every node name
- dbt Cloud IDE shows the same error on compile

## Variant phrasings

### dbt found two resources with the same name
Same error, older wording. The fix is identical: one name, one enabled node.

### duplicate name across packages
Your project and an installed package both define the name. Use enabled: false on the package model via your dbt_project.yml, or rename yours.

## Why it happens

dbt addresses models by name in ref(), so names must be unique across the whole project including installed packages. Duplicates usually come from copying a model as a starting point, or from a folder restructure where the old file was not deleted.

## Edge cases

- Disabled models still show in dbt ls unless you filter; use dbt ls --exclude to sanity check the live DAG.
- Snapshots and seeds share the namespace too, a seed and a model with the same name triggers the same error.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_dOI2H_3Gr3i6Q2LLJp4oNQ
