Problems with capturing new notes in orb from Helm

Hi, migrated to version 2 and all is well.

However, when I try to add a new note from helm-bibtex, the capture template does not work. There is no org-id and just a title.

When I create a new note, it looks like this:

#+TITLE: Notes on: Hawking, S. (1988): Brief History of Time

No org-id, no roam_refs and it ignores the capture template.

Any suggestions?

This is my config:

  ;; Org-Roam configuration
  (use-package org-roam
    :after org
    :init
    (setq org-roam-v2-ack t) ;; Acknowledge V2 upgrade
    :custom
    (org-roam-directory (file-truename "~/Documents/org-roam/"))
    :config
    (setq org-roam-db-location (concat org-roam-directory "data/org-roam.db")
          org-roam-capture-templates '(("d" "default" plain "%?"
                                        :if-new (file+head "${slug}.org"
                                                           "#+title: ${title}\n#+date: %u\n#+lastmod: \n#+startup: inlineimages latexpreview\n*topics*: \n\n")
                                        :unnarrowed t
                                        :immediate-finish t)
                                       ("r" "bibliography reference" plain "%?"
                                        :if-new (file+head "${citekey}.org"
                                                           "#+title: ${title}\n#+date: %U\n#+lastmod: \n#+startup: inlineimages latexpreview\n*topics*: \n\n${fullcite}")
                                        :unnarrowed t
                                        :immediate-finish t))
          org-roam-dailies-capture-templates '(("d" "default" entry "* %?"
                                                :if-new (file+head "%<%Y-%m-%d>.org"
                                                                   "#+title: %<%Y-%m-%d: >\n#+filetags: :Diary:\n\n"))))
    (org-roam-setup)
    :bind
    (("C-c n l" . org-roam-buffer-toggle)
     ("C-c n f" . org-roam-node-find)
     ("C-c n t" . org-roam-tag-add)
     ("C-c n a" . org-roam-alias-add)
     ("C-c n g" . org-roam-ui-mode))
    (:map org-mode-map
          (("C-c n i" . org-roam-node-insert)
           ("C-c n o" . org-id-get-create))))

  (use-package org-roam-bibtex
    :after org-roam
    :bind (:map org-mode-map ("C-c n b" . orb-note-actions))
    :config (require 'org-ref))

Hi, you must activate org-roam-bibtex-mode. Call this command interactively or put (org-roam-bibtex-mode +1) somewhere in your init.el, for example in the :config section of the (use-package org-roam ...) block.

1 Like

Doh! That makes a lot of sense. Thanks.

1 Like

I noticed that you have (org-roam-setup) in your init.el
I just found out that org-roam-setup has been recently removed. Now we should use

(org-roam-db-autosync-mode)
1 Like

@wilya Thank you for this.
I just had a look. You could continue to use org-roam-setup; it’s now an alias for another function org-roam-db-autosync-enable, which in turn activates org-roam-db-autosync-mode.

Long story short, you can use either :slight_smile:

1 Like

Thanks for pointing this out. Hard to keep up with how Org-roam is evolving.

I prefer org-roam-setup, it is more descriptive.

1 Like

Same re “hard to keep up” and same with the sentiment about org-roam-setup; I have kept it, too. It’s shorter :wink:

But to be honest, Jethro and Wetlize are making Herculean efforts to minimize impact on us, the users. I hadn’t noticed this change came in when I update package almost twice a day :). No impact with the recent src directory change, with this name change, with recent modularization for autoload, etc, etc,

I only got to know these via issues experienced by doom and other rather advanced users.

1 Like

What is this change about?

Have a look at the source code directory in GitHub. Some el files are in extensions directory now. No impact on MELPA users.

1 Like

Going a bit off topic here. Be reassured that I wont keep going.

About that, when I updated to V2 (yesterday), I had a bizarre error on start up, concerning org-roam-protocol (something like file not found). In these cases I do the dumb man, scorched earth approach. I delete all my configuration files and start from scratch. Fortunately it is very easy to do so using an org file with all the code blocks to recreate the init file. When I did that, I realized that the error would go away using melpa, but would come back if I install org-roam from git. However, I do not use the normal procedure where I clone locally the repository, but I use quelpa package, which can install from git remotely. I guess it might have been this change of file location.

Anyway, I had to stop using quelpa and the problem went away.

This is the code that initialize quelpa:

  (unless (package-installed-p 'quelpa)
    (with-temp-buffer
      (url-insert-file-contents "https://github.com/quelpa/quelpa/raw/master/quelpa.el")
      (eval-buffer)
      (quelpa-self-upgrade)))

And this is my org-roam configuration, where I commented out the directive to update from git:

    (use-package org-roam
;;;    :quelpa ((org-roam :fetcher github :repo "org-roam/org-roam") :upgrade t)
      :after org
      :ensure t
      :init
      (setq org-roam-v2-ack t)
      ;; for org-roam-buffer-toggle
      (add-to-list 'display-buffer-alist
                   '("\\*org-roam\\*"
                     (display-buffer-in-direction)
                     (direction . right)
                     (window-width . 0.33)
                     (window-height . fit-window-to-buffer)))
      :custom
      (org-roam-directory (file-truename "/Users/cfusco/Nextcloud/work/zettelkasten"))
      (org-roam-dailies-directory "daily/")
      (org-roam-completion-everywhere t)
      :config
      (org-roam-db-autosync-mode) ;; starts org-roam, which is a major mode. org-roam-setup is an alias
      (require 'org-roam-protocol)
      :bind
      (("C-c n l" . org-roam-buffer-toggle)
       ("C-c n L" . org-roam-buffer-display-dedicated)
       ("C-c n f" . org-roam-node-find)
       ("C-c n g" . org-roam-graph)
       ("C-c n i" . org-roam-node-insert)
       ("C-c n c" . org-roam-capture)
       ;; Dailies
       ("C-c n j" . org-roam-dailies-capture-today)))

If this is the issue, it’s likely that the issue is just missing a load path.

I am assuming Quelpa downloads the sub-directory of the repo recursively at least for all .el files.

I think it’s simply a matter of adding the following in your org-roam part of use-package.

:init (add-to-list 'load-path "path/to/org-roam/extensions") – in your case, you require org-roam-protocol in the :config section, so add-to-list can be just before the require to let Emacs know where to find the library.

The end result should be something like this:

    (use-package org-roam
      :quelpa ((org-roam :fetcher github :repo "org-roam/org-roam") :upgrade t)
      :after org
      :ensure t
      :init 
      ;; It should not matter add-to-list first or setq first below
      (add-to-list 'load-path "path/to/repos/org-roam/extensions")
      (setq org-roam-v2-ack t)
     ... [rest of config continues]

Congratulations @nobiot , you hit the nail in the head! As you guessed, quelpa downloaded the git code in its configuration folder, compiled org-roam and moved the .elc files under the melpa folder. However it did not compile extensions. Using the add-to-list function on load-path pointed to extensions in the source code, the error went away. Do you think I could have problems in terms of speed using .el files instead of .elc?

EDIT: I found a way to tell quelpa to compile also the extensions folder, but it does keep the extensions files compiled in a separate folder that needs to be included it to the load-path. Annoying because I will need to manually change the init file every time a new release is created, as the name of the folder will change. Anyhow, this is now how init.el looks like:

  (use-package org-roam
    :quelpa ((org-roam :fetcher github :repo "org-roam/org-roam" :files (:defaults "extensions")) :upgrade t)
    :after org
    :ensure t
    :init
    (add-to-list 'load-path "~/.emacs.d/elpa/org-roam-20210810.802/extensions") ;;; extension folder needs to be included in the load-path
[...] 

Just out of curiosity; I don’t use Quelpa.

Why do you opt to use a receipt, instead of simply going with (quelpa 'org-roam)?

I just tried emacs -q (no loading config) and the following script in init.el.

I got both the git repo under quelpa/build and all the org-roam’s .el files including the ones under extentions in a flat structure in one folder according to the MELPA recipe from Org-roam project. They are also all compiled into .elc.

I didn’t need to do anything extra.

I am assuming this can also automatically upgraded (?).

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(setq package-check-signature nil)
(package-refresh-contents)
(package-install 'quelpa)

(quelpa 'org-roam)

because I clearly cannot read proper documentation. Thank you very much @nobiot . It works beautifully.

1 Like

No worries. I’m glad I got to try Quelpa. I might switch to using it; I like it. Thank you.