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

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:

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?

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.

Thank you for the suggestion, that solved it!

1 Like