Org-roam does not update the database, only after Emacs reboot

Hey there,

I have upgraded to v2 and adjusted my configuration accordingly. However, the org-roam database is only updated when I restart Emacs. Is there something wrong in my config with respect to v2?

(use-package org-roam
    :after org
    :custom
    (org-roam-directory "~/org/roam/")
    (org-roam-capture-templates
     '(("d" "default" plain
        "%?"
        :if-new (file+head "${slug}.org" "#+title: ${title}\n")
        :unnarrowed t)
       ("p" "people" plain
        "%?"
        :if-new (file+head "${slug}.org" "#+title: ${title}\n#+filetags: people")
        :unnarrowed t))
    (org-roam-dailies-directory "journal/")
    (org-roam-dailies-capture-templates
     '(("d" "default" entry
        "* %?"
        :if-new (file+head "%<%Y-%m-%d>.org" "#+title: %<%Y-%m-%d>\n#+filetags: journal")
        :empty-lines 1)))
    :bind (("C-c n l" . org-roam-buffer-toggle)
           ("C-c n f" . org-roam-node-find)
           ("C-c n i" . org-roam-node-insert)
           ("C-c n d n" . org-roam-dailies-capture-today)
           ("C-c n d d" . org-roam-dailies-goto-today)
           ("C-c n d Y" . org-roam-dailies-capture-yesterday)
           ("C-c n D y" . org-roam-dailies-goto-yesterday)
           ("C-c n d T" . org-roam-dailies-capture-tomorrow)
           ("C-c n d t" . org-roam-dailies-goto-tomorrow))
    :config
    (org-roam-db-autosync-mode t))

You might have already found the issue, but just in case.

2 things:

  1. (org-roam-capture-templates is not closed properly
  2. Remove :after org

This below works for me.

(use-package org-roam
  ;;:after org
  :custom
  (org-roam-directory "~/org/roam/")
  ;; (org-roam-database-connector 'sqlite-builtin) ; I use sqlite built-in with Emacs 29, instead of the Org-roam default
  (org-roam-capture-templates
   '(("d" "default" plain
      "%?"
      :if-new (file+head "${slug}.org" "#+title: ${title}\n")
      :unnarrowed t)
     ("p" "people" plain
      "%?"
      :if-new (file+head "${slug}.org" "#+title: ${title}\n#+filetags: people")
      :unnarrowed t)))
  (org-roam-dailies-directory "journal/")
  (org-roam-dailies-capture-templates
   '(("d" "default" entry
      "* %?"
      :if-new (file+head "%<%Y-%m-%d>.org" "#+title: %<%Y-%m-%d>\n#+filetags: journal")
      :empty-lines 1)))
  :bind (("C-c n l" . org-roam-buffer-toggle)
         ("C-c n f" . org-roam-node-find)
         ("C-c n i" . org-roam-node-insert)
         ("C-c n d n" . org-roam-dailies-capture-today)
         ("C-c n d d" . org-roam-dailies-goto-today)
         ("C-c n d Y" . org-roam-dailies-capture-yesterday)
         ("C-c n D y" . org-roam-dailies-goto-yesterday)
         ("C-c n d T" . org-roam-dailies-capture-tomorrow)
         ("C-c n d t" . org-roam-dailies-goto-tomorrow))
  :config
  (org-roam-db-autosync-mode t))

Thanks, that did the trick (parenthesis are a pain sometimes :slight_smile:)

On question though: Why removing “:after org”? org-roam depends on org-mode, right? So loading it afterwards would be logical.

I can understand this sentiment. It took me some time to fix this code. The original you pasted failed at start up when I tested it, so that was a clear indication for me.

If you turn on highlighting matching parentheses, you can see that org-roam-capture-temples do not close but the next org-roam-dailies-directory starts. You then press TAB to indent, this indentation changes. That’s another indication that there is unbalanced parentheses.

image

It is logical. But when I had :after org, the keybindings set in :bind didn’t work without loading Org. I want to call org-roam-node-find before that — it is possible and is what is meant by this :bind part. You might like to check this on your end. Or you always load Org first so it may not be an issue for you.

From my testing, I have learned that if you keep :after org, the :bind part also gets deferred to after Org. This means you cannot use these keybindings until you load Org. I don’t think this is what you mean in this part of the configuration. I don’t load Org until I need it because it slows down Emacs startup.

If you remove :after org, you can use the keybindings immediately after startup without Org loaded, and you can use both Org and Org-roam correctly because Org-roam loads Org when it is not yet loaded (via require inside Org-roam’s code).