Many "old" org-roam files invisible upon deletion and re-build of org-roam.db

first of all, thanks for this wonderful piece of software.

I have 42 notes in my org-roam-directory. When I delete my org-roam.db and start emacs again (or run org-roam-db-build-cache for that matter) I would expect all those 42 notes to re-appear in roam. However, only 7 of the 42 files appear in the mini-buffer when I run org-roam-find-file or org-roam-insert.

I tried:

  • de-activating helm in my init.el, but makes no difference, so I guess it has nothing to do with the completion system?
  • opening, editing and saving one of the older files manually => makes the respective file re-appear in org-roam. However, after deleting and re-building the org-roam.db, again only the same 7 files are visible in org-roam. interestingly - unlike editing - touching a file (via $ touch filename.org) makes no difference to its visibility in org-roam

this issue seems to be related to the one described here.

any help/tips are much appreciated!


Emacs (C-h v emacs-version): v26.3
Org-roam from MELPA

What’s the value of C-h v org-roam-db-location?

I had a problem of ‘missing’ files in the DB recently, and it was because I was pointing at the wrong DB due to a misconfiguration.

I found looking in org-roam.db itself with sqlite was useful when figuring this out.

the value of C-h v org-roam-db-location is exactly as set in my init.el, i.e (setq org-roam-db-location "/home/path/to/.../org_roam/org-roam.db")

however, even if I delete this line and let org-roam use the default org-roam-db-location ~/.emacs.d/org-roam.db the same issue persists. i.e. when deleting and re-building the db, still only the same 7 files are visible in org-roam.

for what it’s worth: as I just realised, when starting emacs for the first time after having deleted org-roam.db, the following user-error appears in the mini-buffer:

(org-roam) Processed 0/42 modified files...
(org-roam) Processed 1/42 modified files...
(org-roam) Processed 2/42 modified files...
(org-roam) Processed 3/42 modified files...
(org-roam) Processed 4/42 modified files...
(org-roam) Processed 5/42 modified files...
(org-roam) Processed 6/42 modified files...
user-error: Org property #+roam_key cannot be empty

okay, it turns out I had a few files in which I had set a #+roam_key: property in the heading but left it empty. deleting #+roam_key: from those files or adding a link so the property wouldn’t be empty fixed the issue. deleted db once more and restarted emacs => all files in org-roam-directory are now visible in org-roam. thanks for triggering me onto this further investigation @doubleloop :wink:

1 Like

just wanted to chime in that the trick of just deleting the db file and restarting emacs also worked for me. I’ve had some issues because I had moved my db and it was very frustrating to find nothing wrong with my files (with C-u M-x org-roam-doctor) and still have some files not show up in completion.
The function org-roam-db-build-cache didn’t fix this issue, what command would have? Perhaps org-roam-db-clear? Is fixing these sorts of issues documented anywhere that I missed?

simply deleting the db and restarting did not solve the issue for me - after every restart of emacs the following error would appear in the mini-buffer:

user-error: Org property #+roam_key cannot be empty

the problem was that I had a few files in my org-roam-directory which had the #+roam_key: mentioned in the headline, but no value was specified. as soon as I entered a value for each #+roam_key:, e.g. #+roam_key: http://type-any-url-in-here.com the error disappeared.

so it turns out org-roam cannot start properly without #+roam_key: being properly specified in each file in org-roam-directory. however, org-roam-doctor does not pick up wrong/incomplete #+roam_key: specifications. if I understood the purpose of org-roam-doctor correctly it actually should, no?

btw. a file without any mention of the #+roam_key: label, does not produce any error…

I believe calling org-roam-db-build-cache with an argument will delete the DB file and rebuild it. (Without an argument, it will index new/modified files). org-roam-db-clear will empty the DB without actually deleting the file.