Org-Roam doesn't show nodes that are in subdirectories

What happened?

Org-Roam doesn’t find some of my nodes. The nodes that are not found are nodes that exist in a subdirectory in my Org-Roam-Directory, and the subdirectory is not tracked by the git repository for the org-roam-directory. Taking the subdirectory filepath out of gitignore makes the org-roam nodes visible again (after running org-roam-db-sync).

What did you expect to happen?

My understanding was that org-roam searches recursively within org-roam-directory, and I was unfamiliar with .gitignore modifying this behaviour. Unsure if this is an org-roam thing or a doom thing.

Steps to reproduce

  1. Put your org-roam-directory under git version control.
  2. In org-roam-directory, create a subdirectory that you then will exclude from the git repository by adding the subdirectory filepath to the git repository .gitignore.
  3. Put some Org-Roam nodes into this subdirectory.
  4. Attempt to search for a node that exists in this subdirectory.

System information


Loading data dump...

tl;dr

;; config.el
(after! org-roam
  (setq org-roam-list-files-commands '(find fd fdfind rg)))

How I figured this out

I appreciate it when people explain how they debug issues so I can do it myself next time, so here goes. You can see where functions are bound with M-x where-is (including where-is itself!); most of these tools are bound to sane keybindings, which expedites the process once you’re comfortable. Feel free to follow along.

  1. I assumed you were using org-roam-node-find when you said “attempt to search for a node”. It’s always good to use exact symbol names in reproduction steps.

  2. I checked org-roam-node-find (via helpful-callable) to see if it was ignoring things from the database at runtime. Nothing seemed relevant, so I assumed the node wasn’t making it into the database at all.

  3. I checked org-roam-db-sync to see how it ignored input. It looks it uses org-roam-list-files to get files. Calling helpful-callable while the point (cursor) is on a function will default the input to the function at point, so let’s inspect that. It actually just wraps the internal org--roam-list-files. We need to go deeper!

  4. Here, it looks like org-roam uses external shell commands if defined. Let’s inspect org-roam-list-files-commands with helpful-variable.

  5. Hmm, it looks like the original value defaults to find, but the current value defaults to fd. Let’s see if the Doom module is to blame. doom/help-modules :lang org will take you to the Org module README.

  6. The README is in your Emacs directory alongside the module code, so let’s find-file and visit contrib/roam2.el. Then I +default/search-buffer for fd, and voilà, it looks like +roam2 indeed makes this change, for speed. You could also just search the entire Doom source if you weren’t familiar with the module structure with +default/search-project.

  7. The simple fix is to reorder the executables in your private config. If you really wanted to use fd, you could redefine org-roam--list-files-fd (how I found this is left as an exercise to the reader :wink:) or even submit a PR to make the behavior across executables consistent upstream. I’ve added this to my backlog, but anyone is free to beat me to it. I won’t get to it for at least a week.

2 Likes

hey Liam, thanks so much for the response, I haven’t had a chance to go through all your help in how you were able to debug it yet, but I intend to.

The solution you suggested worked great,

thanks :slight_smile:

1 Like