# Duplicate refs for the same file. How can I rebuild the cache?

**URL:** <https://org-roam.discourse.group/t/duplicate-refs-for-the-same-file-how-can-i-rebuild-the-cache/974>\
**Category:** Troubleshooting\
**Created:** [November 15, 2020, 9:46am UTC](https://org-roam.discourse.group/t/duplicate-refs-for-the-same-file-how-can-i-rebuild-the-cache/974 "2020-11-15T09:46:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brab](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/brab/32/531_2.png) [@brab](https://org-roam.discourse.group/u/brab)\
**Post date:** [November 15, 2020, 9:46am UTC](https://org-roam.discourse.group/t/duplicate-refs-for-the-same-file-how-can-i-rebuild-the-cache/974/1 "2020-11-15T09:46:33Z")

</div>

I was having some issue with some file renaming yesterday, and after trying to fix everything, I’m now in the following situation, where I have this warning:

```auto
Error (org-roam): Duplicate ref //www.arte.tv/fr/videos/077342-000-A/selfie-avoir-16-ans-a-naples/ in:

A: /home/schmitta/Documents/Org/notes/20201114225606-selfie_avoir_16_ans_a_naples.org
B: 20201114225606-selfie_avoir_16_ans_a_naples.org

```

The problem is that the two files are actually the same file. I tried doing `org-roam-db-build-cache`, but the error stays there.

Is there a way to rebuild the cache from scratch?

---

<div class="post-metadata">

**Author:** ![twitchy-ears](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/twitchy-ears/32/448_2.png) [@twitchy-ears](https://org-roam.discourse.group/u/twitchy-ears)\
**Post date:** [November 17, 2020, 12:28am UTC](https://org-roam.discourse.group/t/duplicate-refs-for-the-same-file-how-can-i-rebuild-the-cache/974/2 "2020-11-17T00:28:20Z")

</div>

At a guess the renaming has managed to create two entries in the files table of your org-roam.db (I’m guessing this because org-roam–rename-file-advice calls expand-file-name) and hence when it comes to trying to build the refs table it has two options of where to try and put it.

I can think of a number of ways to fix this (if you check `C-h v org-roam-db-location` you can find the database, its just sqlite so you can go edit it and resolve the issue) but probably the fastest and easiest fix is to do the following:

1. Backup your org-roam.db just in case
2. M-x org-roam-db-clear
3. M-x org-roam-db-build-cache (or just restart emacs)
4. Wait a little while as it processes your org files
5. Boom, new DB has been created fresh.

From what I can tell nothing of value is stored in the org-roam.db, everything is in your org files, so you can wipe out the database and it’ll rebuild it, its just hints to make it run nice and smooth.

---

<div class="post-metadata">

**Author:** ![brab](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/brab/32/531_2.png) [@brab](https://org-roam.discourse.group/u/brab)\
**Post date:** [November 17, 2020, 8:04am UTC](https://org-roam.discourse.group/t/duplicate-refs-for-the-same-file-how-can-i-rebuild-the-cache/974/3 "2020-11-17T08:04:58Z")

</div>

Thank you for the suggestion, that solved it!
