How have people handled org-oam installations running across multiple machines?
With plain old org-mode I’ve had no problem with a directory of .org file, synced across the three machines I use for work and home. But a single shared org-roam directory has turned out to be problematic, as org-roam apparently maintains some kind of file lock on org-roam.db for as long as emacs runs.
If I forget to kill emacs on machine 1, I’ll have an org-roam conflict when I start org-roam on machine 2. My synching mechanism is OneDrive, and the result of a conflict is that I get duplicate copies of org-roam.db with a uniquified name extension. I imagine DropBox, Syncthing, or whatever will have the same problem.
Am I right? Do other people have this problem, and if so, what do you do about it?
Your best bet is to exclude
org-roam.db from being synced. This way, your machine would update their db when it’s needed.
As @zaeph said, excluding
org-roam.db is the right approach. Here are some more details of my own setup along these lines:
- My org-roam directory is in a git repository (like most of my other personal files).
org-roam.db is excluded via
- A cron script runs git-sync on each of my machines. That works fine for me because I never use several devices at once.
git-sync, the cron script runs
if [ "` ls -t | head -1`" != "org-roam.db" ]; then
emacsclient -e '(org-roam-db-build-cache)'
which tells Emacs (always running) to update the cache in
org-roam.db if any other file in my org-roam directory has changed.
@zaeph, thanks. I’ll try that.
@khinsen, thanks for all those details. I haven’t used git-sync before, but it sounds like now is the time to start.
Just for all those OneDrive users out there… OneDrive can only exclude entire folders from syncing, not individual files. The solution is to put org-roam.db outside of your OneDrive folder, and to tell org-roam where it is by customizing the variable
org-roam-db-location, which should the full path to your org-roam.db file, including the filename.
For Syncthing users, you can create a .stignore file, similar to a .gitignore. I have added the org-roam.db file to it and this fixed my problems when using org-roam across multiple machines.
I am using dropbox to sync, and they don’t allow to exclude single files as well.
I have tried your solution, but apparently I can’t change the variable. When I try to save the changed variable I am getting the following error
Symbol's value as variable is void: /path/org-roam\.db.
So I managed to solve this by defining the variable directly in the config file
@roi.holtzman, I don’t understand that error message but I’m glad you’ve got a solution now. It’s exactly what I do inside of
use-package. Here’s the fragment in my
;; other configs
It is possible to exclude single files with Dropbox too:
I had the same issue and added a machine identifier to the database filename. That way, the same
init.el can also be shared across machines.
You can use this if each user’s machine has a different host name:
(setq org-roam-db-location (concat "~/org-roam-" system-name ".db"))
Good to know, thanks. Would you mind sharing the script? Which interval so you use?