Multiple Root directories

Org-roam revolves around the notion of a single org-roam-directory. Has anyone thought about the possibility of making it work with multiple root directories? Why? So then it would be possible to have wholly separated collections of notes. Like for example, to have a collaborative “wiki”, you’d just need to create a git repo and have all the notes contained within. And you wouldn’t have to worry about accidentally or otherwise linking to the notes that are not related or personal.

It would be great to be able to have “vaults” (for the lack of better words I’m using Obsidian.md term here), right?

Perhaps the concept of switchable “contexts”, where one can set up multiple root directories, e.g.: “default”, “work”, “book-club”, “flat-earthers-society”, etc. And the notes of one context would be completely separated from the others?

How difficult would it be to achieve something like that?

2 Likes

This?

https://www.orgroam.com/manual.html#How-do-I-have-more-than-one-Org_002droam-directory_003f

21.1 How do I have more than one Org-roam directory?

Emacs supports directory-local variables, allowing the value of org-roam-directory to be different in different directories. It does this by checking for a file named .dir-locals.el .

To add support for multiple directories, override the org-roam-directory variable using directory-local variables. This is what .dir-locals.el may contain:

((nil . ((org-roam-directory . “.”) (org-roam-db-location . “./org-roam.db”))))

All files within that directory will be treated as their own separate set of Org-roam files. Remember to run org-roam-db-build-cache from a file within that directory, at least once.

This is wonderful and all, but

  • I started using projectile and created a subfolder Kom
  • One .org file I moved there (containing of course red unreferenced links)
  • I created the mentioned file and recreated roam db cache (even deleted the org-roam.db)
  • ERROR: refused to use unsafe local variable…

Could you please help me out here?

Thank you in advance and have a nice day.

if you are asking me, I have no idea. I just referenced a section in the documentation. I don’t use it myself. …also I’m not sure if the error you see is related to this (?)

The example content for .dir-locals.el given in the documentation did not work in my case. When calling org-roam-db-build-cache for one of my org-roam root-directories, a UNIQUE constraint failed: files.file error always occured – even if the database was deleted first.

What does work for .dir-locals.el is the following:

((nil . ((eval . (progn
                   (setq-local org-roam-directory (locate-dominating-file default-directory ".dir-locals.el"))
                   (setq-local org-roam-db-location (concat org-roam-directory "org-roam.db")))))))

Therefore the constraint error mentioned above appears to happen when org-roam-directory and org-roam-db-location are not set using absolute paths.

I wonder if it would make sense to update the documentation to use something like my example above?

2 Likes