My org-roam-directory is being ignored…

I’ve customised org-roam-directory to point to my org-roam notes directory. Up until I started Emacs today (after a few days not using it) this worked fine. Today, org-roam has reverted to ~/org-roam. I’m using Spacemacs so maybe it’s something to do with that? Any suggestions?

It turns out that if I do M-x org-roam-db-build-cache org-roam springs back into life with the correct directory.

Could this be a load order thing, that the customize settings somehow get loaded after the Spacemacs layer?

It’s very hard to comment. It’s very hard to imagine Spacemacs has automatically changed configuration. It’s more likely that someone has influenced this. If you are the only user, then… I could only speculate the following. Not exhaustive, and may not be mutually exclusive. But probably one of them. Point 2 is relevant for load sequence you commented. And 3. can be eliminated (I believe). How about point 1?

  1. You upgraded Spacemacs, or changed some layer and it inadvertently influenced Org-roam configuration (or maybe load sequence)

  2. You had a different sequence of operations to open Org-roam

  3. You actually changed the configuration for Org-roam

I agree that it’s kinda painful figuring these ones out — sometimes I wish I could just have someone as a contractor to figure out my Emacs config!

(1.) is definitely the most likely, but super difficult to figure out for a mortal like me. (2.) is also probable - in the *Messages* buffer I can see that as part of the load sequence, the org-roam cache is being rebuilt in the wrong directory:

Starting new Ispell process /usr/local/bin/aspell with default dictionary...done
(org-roam) Processed 0/1 modified files...
(org-roam) total: ∆1, files-modified: ∆1, ids: ∆0, links: ∆0, tags: ∆0, titles: ∆1, refs: ∆0, deleted: ∆70
Spacemacs is ready.

But when I look in the Spacemacs org package layer, I can’t see anything in the layer definition or package load that should trigger anything before the customize options get loaded.

If, however, I add (setq org-roam-directory "/Users/lyndon/repo/notes/roam") to dotspacemacs/user-init() (which is called before any packages are loaded) the whole thing works properly. So there must be some annoying change in the load order in the Spacemacs org layer :frowning:

One option is to quit Spacemacs.

If this is not your option, one thing you could try is to ensure to evaluate setq as late as possible.

(with-eval-after-load 'org-roam
  (setq org-roam-db-location "~/test.db")

This just worked in my vanilla environment. You can (and need to) put it before the package has been loaded, so it should work if you put it in your user-init. I think what it does is obvious from the name of the function.

I do not know Spacemacs, but it might use use-package like Doom does. I haven’t really looked into use-package but I understood that it is essentially a set of clever macros to expose with-eval-after-load and others in a user-friendly way for ease of organizing many packages.