# schema yaml for macro complaining two macros with the same name

**URL:** <https://discourse.getdbt.com/t/schema-yaml-for-macro-complaining-two-macros-with-the-same-name/7554>\
**Category:** Help\
**Tags:** documentation, custom-schema, macros\
**Created:** [March 29, 2023, 3:30pm UTC](https://discourse.getdbt.com/t/schema-yaml-for-macro-complaining-two-macros-with-the-same-name/7554 "2023-03-29T15:30:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiangshi.yin](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/xiangshi.yin/32/2064_2.png) [@xiangshi.yin](https://discourse.getdbt.com/u/xiangshi.yin)\
**Post date:** [March 29, 2023, 3:30pm UTC](https://discourse.getdbt.com/t/schema-yaml-for-macro-complaining-two-macros-with-the-same-name/7554/1 "2023-03-29T15:30:30Z")

</div>

## The problem I’m having

When adding two entries of macros in `property.yml`, `dbt compile` has the following complain:

```sh
02:17:51 Encountered an error:
Compilation Error
  dbt found two macros named "macro2" in the project "xxx".
   To fix this error, rename or remove one of the following macros:
      - macros/utils/a_file_with_2_macros_defined.sql
      - macros/utils/a_file_with_2_macros_defined.sql

```

## The context of why I’m trying to do this

Initially there was only 1 macro `macro1` defined in `macros/utils/a_file_with_2_macros_defined.sql` and the `property.yml` is like below and everything works just fine.

```yaml
version: 2

macros:
  - name: macro1
    description: ""
    arguments: ""

```

Then I added an additional macro `macro2` to the same `sql` file and the `property.yml` file is changed to something below. But `dbt compile` starts to pop up the complains. If I remove the entry from `property.yml` file, everything works just fine and the data model consuming the new macro also works fine.

Anyone has any clue on what’s going on here? I’m pretty sure I don’t have two macros with the same name in my project.

```yaml
version: 2

macros:
  - name: macro1
    description: ""
    arguments: ""
  - name: macro2
    description: ""
    arguments: ""

```

---

<div class="post-metadata">

**Author:** ![GSokol](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/gsokol/32/2958_2.png) [@GSokol](https://discourse.getdbt.com/u/GSokol)\
**Post date:** [September 8, 2023, 7:56am UTC](https://discourse.getdbt.com/t/schema-yaml-for-macro-complaining-two-macros-with-the-same-name/7554/2 "2023-09-08T07:56:17Z")

</div>

Have the same issue. Remove everything in the target directory. That might help.

---

<div class="post-metadata">

**Author:** ![jeancochrane](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/jeancochrane/32/2895_2.png) [@jeancochrane](https://discourse.getdbt.com/u/jeancochrane)\
**Post date:** [November 14, 2024, 11:20pm UTC](https://discourse.getdbt.com/t/schema-yaml-for-macro-complaining-two-macros-with-the-same-name/7554/3 "2024-11-14T23:20:36Z")

</div>

Has anyone found a sustainable solution to this problem? It’s annoying that basically every time I edit a test in a `schema.yml` file and rerun it, I have to first delete the target directory so that dbt doesn’t raise this error.
