Links not working


I recently upgraded to Org-Roam version 2. I have also used org-roam-migration-wizard.

At the moment, the links to other articles internal to Org-Roam, do not work. I get the error:

Cannot find entry with ID “4f4771ca-8527-4191-a287-c00ef6b3677a”

(ID-number depending on the link I activate.)

I have tried org-roam-db-clear-all, followed by org-roam-db-sync.

Below is the output of Org-Roam diagnostics:

  • Emacs: GNU Emacs 27.2 (build 1, x86_64-apple-darwin20.4.0, Carbon Version 164 AppKit 2022.44)
    of 2021-05-05
  • Framework: Doom
  • Org: Org mode version 9.5 (9.5-b83ae59 @ /Users/atmboelens/.emacs.d/.local/straight/build-27.2/org/)
  • Org-roam: 2.0.0

I had the same issue and this helped: Org-roam V2 / org-id ID link resolution problem - #4 by nobiot

i.e. evaluating

(org-id-update-id-locations (org-roam--list-all-files))

However I have needed to run it twice now, which takes a long time, so I assume there is something additional that needs doing to keep this synced.

Hi doubleloop, thanks!

This solved the issue.

You should not need to call that function twice.
It goes through all the notes and can take long; it should be a one time thing.

You should not need to update org-id-locations-file for each node unless you are using your custom ID (not generated by one of the org-id functions).

I use something like this below because I prefer my Org-ID to be in my own timestamp format. You should not have to use it if you use the normal Org-ID and Org-roam functions.

(defun my/org-id-update-location-at-org-roam-db-insert-file ()
  "Update `org-id-locations-file' and hash table.
It's meant to be used with `advice-add' :after
`org-roam-db-insert-file'.  We can assume that this function is
run wihtin a buffer visiting a file being inserted, as
insert-file is run within `org-roam-with-file' macro."
    (when-let ((id (org-entry-get 1 "id")))
      (org-id-add-location id (buffer-file-name))))

 (advice-add #'org-roam-db-insert-file :after
1 Like

A-ha, thanks. I am using the standard org-id functions I believe, so perhaps I did something which cleared org-id-locations-file somehow. I haven’t had to run the update again, as of yet.

1 Like

You should not need to update org-id-locations-file for each node unless you are using your custom ID (not generated by one of the org-id functions).

My org-id-method is uuid, yet currently I find if I add a new node, via org-roam-node-insert, the following is required:

  • in order for it to subsequently appear in the list of completions, I need to run org-roam-db-sync
  • in order to navigate to it via selecting a link within an org file, I have to first add the id location with org-id-add-location

As you say, I don’t think this is the expected behaviour, but I’m not sure why it is happening.

The need for calling db-sync suggests to me that your hooks are not correctly set. You might like to check variable after-save-hook. It is probably locally set, so check this in your org-roam file. You should see some org-roam related function to take care of db file/node update. If you don’t see it, check if you call org-roam-setup in your init.

1 Like

I was not running org-roam-setup anywhere. I’ve added it in to my spacemacs user-config function now, and this is working. Thank you!

1 Like

I suspect org-id part of the issue might be different (org-roam-setup itself does not do anything for org-id-locations-file). You might like to check if adding a new node also correctly updates the org-id-locations-file… You should not have to call function org-id-add-location

For reference for any other spacemacs users seeing this - the call to (org-roam-setup) is now in the org layer, so you don’t need to add it to your own user-config.