With org-roam, Doom Emacs hangs for a long time at startup

I’ve migrated to v2 on Saturday. The migration itself went well, but then I had issues with org-roam-db-sync hanging after processing some percentage of the files (always 7%) (despite org-roam-migrate-wizard processing all the files alright the first time). After spending a lot of time on this, here’s where I am right now:

  • on up to date arch linux
  • move .emacs.d, .doom.d somewhere else
  • rm -rf ~/org-roam

Doom Emacs install:

git clone https://github.com/hlissner/doom-emacs ~/.emacs.d
~/.emacs.d/bin/doom install

Add the following to ~/.doom.d/packages.el:

(package! org-roam
  :recipe (:host github :repo "org-roam/org-roam"))

Add the following to ~/.doom.d/config.el:

(use-package! org-roam)

Run doom sync. Run emacs.
Then it’s hanging seemingly forever. Or maybe just for a long time, I’ve seen it finish initialization after 20 minutes yesterday (but then, same issue with org-roam-db-sync). Right now it’s probably been at least 45 minutes. I know I’m not on native-comp but feels a bit lengthy.

However, if I follow the instructions here, i.e. don’t use Doom Emacs, everything works well. I can even run org-roam-db-sync on my entire collection without an issue.

A bit lost here.

For doom, do you set the +roam2 flag for the org module?

No, I wanted to set up org-roam myself.

But thanks for reminding me of that flag. I’ll try it soon, in case it works this way, but if it does I would still be puzzled by the current behavior.

I see…
OK. Two things I notice.

1. package.el

If you use the package! to get the program files from GitHub like you do, I guess it does not pull all the dependencies – I can be wrong so I suggest that you ensure that it has pulled all the dependencies.

If you don’t set it to use GitHub, then it should switch to using MELPA, which should also pull all the dependencies together – again, sorry I don’t use doom so please validate what I am saying here on your end.

The key thing that you should make sure is that all the packages required to run Org-roam have been correctly installed.

See this part of README in Org-roam repository on GitHub:

2. config.el

package! does not do anything to configure the library. I think this is clearly documented in doom’s documentation. Use something like use-package!. I think if you look at this forum, or doom’s Discord, you will see a sample configuration by someone else.

One common mistake I have seen is related to (setq org-roam-v2-ack t). It needs to be set before org-roam is loaded (e.g. by require), so it needs to be set in the :init part of use-package!.

If this confuses you, I suggest you stick with the +roam2 flag – it should take care of org-roam-v2-ack and other things for you – but you still need to fix the package! part for installation. Installation and configuration are two different things.

Thanks!

I’m sorry, I mistyped my first post with (package! org-roam) in .doom.d/config.el, I was already using (use-package! org-roam). I’ve edited the initial post.

So I also tried the exact recipe given in the README:

(package! org-roam
  :recipe (:host github :repo "org-roam/org-roam"
           :files (:defaults "extensions/*")))

(previously I wasn’t using :files, as I was simply keeping my old v1 config and hadn’t looked at the new instructions).
But it didn’t change anything (same issue after running doom sync -u)

(org +roam2) in .doom.d/init.el works fine.

I think you’re right, it’s probably an issue of missing dependencies. Especially since, now that I think about it, my initial issue got worse as I was trying to isolate it (by removing the rest of my config). I assumed that the package! macro pulled dependencies somehow, but I don’t find this (or the contrary) documented anywhere. Maybe that wasn’t a safe assumption. I’m not going to investigate further though.

Thanks for your help! I’ll be using the +roam2 flag for the time being.