Anyone got v2 working with spacemacs or on Ubuntu at all?

I very recently came across org-roam and wanted to evaluate it for my needs (I’ve been using org-mode for some time). It looks very promising and after some reading and trying I thought to test the new branch v2. For what I think I will need, I guess v2 is the way to go and since I’m anyway starting new, I wanted to give it a shot. However, I kind of got stuck and after I have been meddling with this for the better part of a week now without significant progress I dearly hope someone here can help me.

  1. Using this config from Jethro,

    (use-package! org-roam
    :init
    (map! :leader
        :prefix "n"
        :desc "org-roam" "l" #'org-roam-buffer-toggle
        :desc "org-roam-node-insert" "i" #'org-roam-node-insert
        :desc "org-roam-node-find" "f" #'org-roam-node-find
        :desc "org-roam-ref-find" "r" #'org-roam-ref-find
        :desc "org-roam-show-graph" "g" #'org-roam-show-graph
        :desc "org-roam-capture" "c" #'org-roam-capture
        :desc "org-roam-dailies-capture-today" "j" #'org-roam-dailies-capture-today)
    (setq org-roam-directory (file-truename "~/.org/braindump/org/")
        org-roam-db-gc-threshold most-positive-fixnum
        org-id-link-to-org-use-id t)
    (add-to-list 'display-buffer-alist
               '(("\\*org-roam\\*"
                  (display-buffer-in-direction)
                  (direction . right)
                  (window-width . 0.33)
                  (window-height . fit-window-to-buffer))))
    :config
    (setq org-roam-mode-sections
        (list #'org-roam-backlinks-insert-section
              #'org-roam-reflinks-insert-section
              ;; #'org-roam-unlinked-references-insert-section
              ))
    (org-roam-setup)
    (setq org-roam-capture-templates
        '(("d" "default" plain
           "%?"
           :if-new (file+head "${slug}.org"
                              "#+title: ${title}\n")
           :immediate-finish t
           :unnarrowed t)))
    (setq org-roam-capture-ref-templates
        '(("r" "ref" plain
           "%?"
           :if-new (file+head "${slug}.org"
                              "#+title: ${title}\n")
           :unnarrowed t)))
    

    I can make v2 working with doom on MacOS. As I’m used to spacemacs and I like the theme for org better as for doom (I know, probably not the best reason :slight_smile: ) I tried to make v2 work with spacemacs without luck.
    This is my minimalistic relevant configuration part:

    (add-to-list 'load-path "~/.emacs.d/private/org-roam")
    (require 'org-roam)
    ;   (require 'org-roam-graph)
    (require 'org-roam-protocol)
    (setq org-roam-directory "~/data/Notes/roam/"
    

    For capture I get an error
    Could not read org-id-values from /Users/ben/.emacs.d/.cache/.org-id-locations. Setting it to nil. only after I manually call org-roam-setup can the new note be found with org-roam-node-insert
    The note only shows up after I manually do org-roam-db-sync.
    The backlink buffer also doesn’t work as expected unlike in doom:

    So my question is if there’s anyone out there who’s got a similar config as the one posted for doom working for spacemacs?

  2. I also tried to install doom on a recent Ubuntu 20.04 with even less success. I tried the shipped emacs 26.3 and a self-compiled 27.2.
    org-roam-setup crashed with a cryptic error message:

    Debugger entered--Lisp error: (void-function file)
    file(nil)
    org-roam-db-sync()
    org-roam-setup()
    eval-buffer(#<buffer  *load*-973080> nil "/home/amelie/.doom.d/config.el" nil t)  ; Reading at buffer    position 15058
    load-with-code-conversion("/home/amelie/.doom.d/config.el" "/home/amelie/.doom.d/config.el" t t)
    load("/home/amelie/.doom.d/config" t nomessage)
    (let (file-name-handler-alist) (load (expand-file-name "config" doom-private-dir) t (quote nomessage)))
    (condition-case e (let (file-name-handler-alist) (load (expand-file-name "config" doom-private-dir) t    (quote nomessage))) ((debug doom-error) (signal (car e) (cdr e))) ((debug error) (doom--handle-load-  error e (expand-file-name "config" doom-private-dir) doom-private-dir)))
    (if no-config-p nil (maphash (doom-module-loader doom-module-config-file) doom-modules) (run-hook-wrapped (quote doom-init-modules-hook) (function doom-try-run-hook)) (condition-case e (let (file-name-handler-alist) (load (expand-file-name "config" doom-private-dir) t (quote nomessage))) ((debug doom-error) (signal (car e) (cdr e))) ((debug error) (doom--handle-load-error e (expand-file-name "config" doom-private-dir) doom-private-dir))) (load custom-file (quote noerror) (not doom-debug-mode)))
    (progn (if doom-debug-p (progn (let ((inhibit-message (active-minibuffer-window))) (message #("DOOM Initializing user config" 0 5 (face font-lock-comment-face)))))) (maphash (doom-module-loader doom-module-init-file) doom-modules) (run-hook-wrapped (quote doom-before-init-modules-hook) (function doom-try-run-hook)) (if no-config-p nil (maphash (doom-module-loader doom-module-config-file) doom-modules) (run-hook-wrapped (quote doom-init-modules-hook) (function doom-try-run-hook)) (condition-case e (let (file-name-handler-alist) (load (expand-file-name "config" doom-private-dir) t (quote nomessage))) ((debug doom-error) (signal (car e) (cdr e))) ((debug error) (doom--handle-load-error e (expand-file-name "config" doom-private-dir) doom-private-dir))) (load custom-file (quote noerror) (not doom-debug-mode))))
    (if init-p (progn (if doom-debug-p (progn (let ((inhibit-message (active-minibuffer-window))) (message #("DOOM Initializing user config" 0 5 (face font-lock-comment-face)))))) (maphash (doom-module-loader doom-module-init-file) doom-modules) (run-hook-wrapped (quote doom-before-init-modules-hook) (function doom-try-run-hook)) (if no-config-p nil (maphash (doom-module-loader doom-module-config-file) doom-modules) (run-hook-wrapped (quote doom-init-modules-hook) (function doom-try-run-hook)) (condition-case e (let (file-name-handler-alist) (load (expand-file-name "config" doom-private-dir) t (quote nomessage))) ((debug doom-error) (signal (car e) (cdr e))) ((debug error) (doom--handle-load-error e (expand-file-name "config" doom-private-dir) doom-private-dir))) (load custom-file (quote noerror) (not doom-debug-mode)))) nil)
    (let* ((init-p (and t (condition-case e (let (file-name-handler-alist) (load (expand-file-name doom-module-init-file doom-private-dir) t (quote nomessage))) ((debug doom-error) (signal (car e) (cdr e))) ((debug error) (doom--handle-load-error e (expand-file-name doom-module-init-file doom-private-dir) doom-private-dir)))))) (if init-p (progn (if doom-debug-p (progn (let ((inhibit-message ...)) (message #("DOOM Initializing user config" 0 5 (face font-lock-comment-face)))))) (maphash (doom-module-loader doom-module-init-file) doom-modules) (run-hook-wrapped (quote doom-before-init-modules-hook) (function doom-try-run-hook)) (if no-config-p nil (maphash (doom-module-loader doom-module-config-file) doom-modules) (run-hook-wrapped (quote doom-init-modules-hook) (function doom-try-run-hook)) (condition-case e (let (file-name-handler-alist) (load (expand-file-name "config" doom-private-dir) t (quote nomessage))) ((debug doom-error) (signal (car e) (cdr e))) ((debug error) (doom--handle-load-error e (expand-file-name "config" doom-private-dir) doom-private-dir))) (load custom-file (quote noerror) (not doom-debug-mode)))) nil))
    (progn (setq doom-init-modules-p t) (if no-config-p nil (if doom-debug-p (progn (let ((inhibit-message (active-minibuffer-window))) (message #("DOOM Initializing core modules" 0 5 (face font-lock-comment-face)))))) (doom-initialize-core-modules)) (let* ((init-p (and t (condition-case e (let (file-name-handler-alist) (load ... t ...)) ((debug doom-error) (signal ... ...)) ((debug error) (doom--handle-load-error e ... doom-private-dir)))))) (if init-p (progn (if doom-debug-p (progn (let (...) (message #("DOOM Initializing user config" 0 5 (face font-lock-comment-face)))))) (maphash (doom-module-loader doom-module-init-file) doom-modules) (run-hook-wrapped (quote doom-before-init-modules-hook) (function doom-try-run-hook)) (if no-config-p nil (maphash (doom-module-loader doom-module-config-file) doom-modules) (run-hook-wrapped (quote doom-init-modules-hook) (function doom-try-run-hook)) (condition-case e (let (file-name-handler-alist) (load ... t ...)) ((debug doom-error) (signal ... ...)) ((debug error) (doom--handle-load-error e ... doom-private-dir))) (load custom-file (quote noerror) (not doom-debug-mode)))) nil)))
    (if (or force-p (not doom-init-modules-p)) (progn (setq doom-init-modules-p t) (if no-config-p nil (if doom-debug-p (progn (let ((inhibit-message ...)) (message #("DOOM Initializing core modules" 0 5 (face font-lock-comment-face)))))) (doom-initialize-core-modules)) (let* ((init-p (and t (condition-case e (let ... ...) (... ...) (... ...))))) (if init-p (progn (if doom-debug-p (progn (let ... ...))) (maphash (doom-module-loader doom-module-init-file) doom-modules) (run-hook-wrapped (quote doom-before-init-modules-hook) (function doom-try-run-hook)) (if no-config-p nil (maphash (doom-module-loader doom-module-config-file) doom-modules) (run-hook-wrapped (quote doom-init-modules-hook) (function doom-try-run-hook)) (condition-case e (let ... ...) (... ...) (... ...)) (load custom-file (quote noerror) (not doom-debug-mode)))) nil))))
    doom-initialize-modules(nil)
    (progn (setq doom-init-p t) (if doom-debug-p (progn (let ((inhibit-message (active-minibuffer-window))) (message #("DOOM Initializing Doom" 0 5 (face font-lock-comment-face)))))) (setq-default exec-path doom--initial-exec-path load-path doom--initial-load-path process-environment doom--initial-process-environment) (condition-case e (load (string-remove-suffix ".el" doom-autoloads-file) nil (quote nomessage)) (file-missing (if (locate-file doom-autoloads-file load-path) (signal (quote doom-autoload-error) e) (signal (quote doom-error) (list "Doom is in an incomplete state" "run 'doom sync' on the command line to repair it"))))) (if (or (display-graphic-p) (daemonp)) (doom-load-envvars-file doom-env-file (quote noerror))) (require (quote core-modules)) (autoload (quote doom-initialize-packages) "core-packages") (eval-after-load (quote package) (function (lambda nil (require (quote core-packages))))) (eval-after-load (quote straight) (function (lambda nil (doom-initialize-packages)))) (add-hook (quote doom-first-buffer-hook) (function gcmh-mode)) (add-hook (quote after-change-major-mode-hook) (function doom-run-local-var-hooks-h)) (add-hook (quote emacs-startup-hook) (function doom-load-packages-incrementally-h)) (add-hook (quote window-setup-hook) (function doom-display-benchmark-h)) (doom-run-hook-on (quote doom-first-buffer-hook) (quote (after-find-file doom-switch-buffer-hook))) (doom-run-hook-on (quote doom-first-file-hook) (quote (after-find-file dired-initial-position-hook))) (doom-run-hook-on (quote doom-first-input-hook) (quote (pre-command-hook))) (if doom-debug-p (doom-debug-mode 1)) (doom-initialize-modules force-p))
    (if (or force-p (not doom-init-p)) (progn (setq doom-init-p t) (if doom-debug-p (progn (let ((inhibit-message (active-minibuffer-window))) (message #("DOOM Initializing Doom" 0 5 (face font-lock-comment-face)))))) (setq-default exec-path doom--initial-exec-path load-path doom--initial-load-path process-environment doom--initial-process-environment) (condition-case e (load (string-remove-suffix ".el" doom-autoloads-file) nil (quote nomessage)) (file-missing (if (locate-file doom-autoloads-file load-path) (signal (quote doom-autoload-error) e) (signal (quote doom-error) (list "Doom is in an incomplete state" "run 'doom sync' on the command line to repair it"))))) (if (or (display-graphic-p) (daemonp)) (doom-load-envvars-file doom-env-file (quote noerror))) (require (quote core-modules)) (autoload (quote doom-initialize-packages) "core-packages") (eval-after-load (quote package) (function (lambda nil (require (quote core-packages))))) (eval-after-load (quote straight) (function (lambda nil (doom-initialize-packages)))) (add-hook (quote doom-first-buffer-hook) (function gcmh-mode)) (add-hook (quote after-change-major-mode-hook) (function doom-run-local-var-hooks-h)) (add-hook (quote emacs-startup-hook) (function doom-load-packages-incrementally-h)) (add-hook (quote window-setup-hook) (function doom-display-benchmark-h)) (doom-run-hook-on (quote doom-first-buffer-hook) (quote (after-find-file doom-switch-buffer-hook))) (doom-run-hook-on (quote doom-first-file-hook) (quote (after-find-file dired-initial-position-hook))) (doom-run-hook-on (quote doom-first-input-hook) (quote (pre-command-hook))) (if doom-debug-p (doom-debug-mode 1)) (doom-initialize-modules force-p)))
    doom-initialize()
    eval-buffer(#<buffer  *load*> nil "/home/amelie/.emacs.d/init.el" nil t)  ; Reading at buffer position 2110
    load-with-code-conversion("/home/amelie/.emacs.d/init.el" "/home/amelie/.emacs.d/init.el" t t)
    load("/home/amelie/.emacs.d/init" t t)
    #f(compiled-function () #<bytecode 0x1e0f4d>)()
    command-line()
    normal-top-level()
    

    I’m pretty clueless as to why this would not even work at all. Btw, manually calling org-roam-setup creates a database but it’s empty. The setup is the same as on the Mac.

My apologies if it’s something obvious, but I stopped seeing the trees in the forst.
Thank you very much in advance and any help is much appreciated.

Best

Ben

Hi Ben,

I am guessing you only need Spacemacs to work, correct?

Have you had a chance to read the wiki, and perhaps tried to apply this vanilla config to Spacemacs?

Once variables have been set via setq and/or use-package, etc. (I don’t know how Spacemacs does this), you need to run org-roam-setup.

You say this:

only after I manually call org-roam-setup can the new note be found with org-roam-node-insert`

This is because… You need to do it – you will notice it added in part of the config above. There is no minor-mode to start Org-roam. org-roam-setup is the way to start it.

And then refer to this section on how you can use V2.

I am guessing the reason why you see nothing in the org-roam buffer is because you haven’t set up the sections to display. See this part:

(setq org-roam-mode-sections
    (list #'org-roam-backlinks-insert-section
          #'org-roam-reflinks-insert-section
          ;; #'org-roam-unlinked-references-insert-section
          ))

I think you can run org-roam in Spacemacs now… Let us know…

Dear Nobiot
yes, I did read the wiki, but apparently didn’t understand…
It works like a charm on Mac :smiley: and I will try Ubuntu tomorrow. Thanks a million!
Here’s my org-roam related dotspacemacs/user-config part for reference:

   (defun my/org-roam-load ()
       (interactive)
       (add-to-list 'load-path "~/.emacs.d/private/org-roam")
       (load-library "org-roam")
       (setq org-roam-directory "~/data/Notes/roam/")
       (setq org-roam-mode-sections
           (list #'org-roam-backlinks-insert-section
                 #'org-roam-reflinks-insert-section;))
                 #'org-roam-unlinked-references-insert-section))
       (setq org-roam-file-extensions '("org"))
       (org-roam-setup)
       ; capture files without date-time prefix
       (setq org-roam-capture-templates
           '(("d" "default" plain
               "%?"
              :if-new (file+head "${slug}.org"
                                 "#+title: ${title}\n")
              :immediate-finish t
              :unnarrowed t)))
        (setq org-roam-capture-ref-templates
            '(("r" "ref" plain
               "%?"
               :if-new (file+head "${slug}.org"
                                  "#+title: ${title}\n")
               :unnarrowed t)))
    )
    (my/org-roam-load)
   (spacemacs/declare-prefix "ar" "org-roam")
   (spacemacs/set-leader-keys
     "ar/" 'org-roam-node-find
     "arc" 'org-roam-capture
     "ari" 'org-roam-node-insert
     "arr" 'org-roam-buffer-toggle)
   (spacemacs/declare-prefix-for-mode 'org-mode "mr" "org-roam")
   (spacemacs/set-leader-keys-for-major-mode 'org-mode
     "r/" 'org-roam-node-find
     "rc" 'org-roam-capture
     "ri" 'org-roam-node-insert
     "rr" 'org-roam-buffer-toggle)
   (define-key evil-insert-state-map (kbd "C-c i") 'org-roam-capture)

Cheers

Ben

This part defines a function you can manually run. Did you you call it?

Maybe you are calling it.

And it does not work?

If it works on Mac and not on Ubuntu, it might be that the Emac version is different.

Dear Nobiot,
all it’s working now :smiley:. On Ubuntu I had to use the new Emacs 27.2. I’m pretty stumped as to why this was such a struggle previously, but I’m happy that I’m operational now.
Thanks a lot

Ben

1 Like

Why am I getting this error message each time I tried to write a new node?

user-error:

Template needs to specify ‘:if-new’

That’s because the capture template has introduced new syntax (wiki).