# Org-roam V2 / org-id ID link resolution problem

**URL:** <https://org-roam.discourse.group/t/org-roam-v2-org-id-id-link-resolution-problem/1491>\
**Category:** Troubleshooting\
**Created:** [April 19, 2021, 1:06pm UTC](https://org-roam.discourse.group/t/org-roam-v2-org-id-id-link-resolution-problem/1491 "2021-04-19T13:06:44Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![S\_Fabris](https://avatars.discourse-cdn.com/v4/letter/s/a8b319/32.png) [@S\_Fabris](https://org-roam.discourse.group/u/S_Fabris)\
**Post date:** [April 19, 2021, 1:06pm UTC](https://org-roam.discourse.group/t/org-roam-v2-org-id-id-link-resolution-problem/1491/1 "2021-04-19T13:06:45Z")

</div>

After upgrading to V2 and migrating all notes (adding an automatic ID property with org-id-get-create) and moving the Aliases inside the property drawer, I get some strange behaviour:

- Updating the db runs fine, no errors. All files are cached
- org-roam buffer with backlinks works
- newly created notes can be linked and traversed to
- org-roam find node works

However, all previously exisiting notes cannot be retrieved when clicked on links. Emacs throws an "Cannot find entry with ID: “XXXXXX” error, which is clearly an org-id error.

I thought org-roam somehow overrides org-id link functionality? Where does this happen in the code?  
Or am I mistaken here and I need to rely on org-id-locations and add the full org-roam folder to the org-id-extra-files?

---

<div class="post-metadata">

**Author:** ![spicy](https://avatars.discourse-cdn.com/v4/letter/s/2acd7d/32.png) [@spicy](https://org-roam.discourse.group/u/spicy)\
**Post date:** [April 19, 2021, 2:11pm UTC](https://org-roam.discourse.group/t/org-roam-v2-org-id-id-link-resolution-problem/1491/2 "2021-04-19T14:11:49Z")

</div>

I have the same exact problem, for old notes I need to delete the id and create it again for the links to work.  
Pretty manual but I have to manually change all the file links for id links anyways. I guess I should try to create some elisp to perform this automatically

---

<div class="post-metadata">

**Author:** ![mshevchuk](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@mshevchuk](https://org-roam.discourse.group/u/mshevchuk)\
**Post date:** [April 19, 2021, 2:50pm UTC](https://org-roam.discourse.group/t/org-roam-v2-org-id-id-link-resolution-problem/1491/3 "2021-04-19T14:50:16Z")

</div>

> [@S\_Fabris](#):
>
> I thought org-roam somehow overrides org-id link functionality? Where does this happen in the code?

It happened in the v1 in the function `org-roam-link-follow-link`:

```elisp
(defun org-roam-link-follow-link (_path)
  ...
  (pcase-let ((`(,link-type ,loc ,desc ,mkr) (org-roam-link--get-location)))
    ...
      ("id"
       (org-goto-marker-or-bmk mkr)))))

```

It does not happen in v2 anymore:

```elisp
(defun org-roam-link-follow-link (path)
   ...
  (pcase-let ((`(,id ,file ,pos) (org-roam-link-locate)))
   ...
    (org-id-goto id)))

```

So I guess one has to rely on `org-id-locations`. This could help find all the already existing relevant files:

```elisp
(setq org-id-extra-files (find-lisp-find-files org-roam-directory "\.org$"))

```

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [April 19, 2021, 3:56pm UTC](https://org-roam.discourse.group/t/org-roam-v2-org-id-id-link-resolution-problem/1491/4 "2021-04-19T15:56:21Z")

</div>

@S_Fabris @spicy

In addition to @mshevchuk’s suggestion, this function might also work to update the org-id-locations. [Source here](https://org-roam.discourse.group/t/nroam-org-roam-backlinks-within-org-mode-buffers/1306/2).

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

```

I have functions out of this principle:

```auto
(defun my/org-id-update-org-roam-files ()
  "Update Org-ID locations for all Org-roam files."
  (interactive)
  (org-id-update-id-locations (org-roam--list-all-files)))

(defun my/org-id-update-id-current-file ()
  "Scan the current buffer for Org-ID locations and update them."
  (interactive)
  (org-id-update-id-locations (list (buffer-file-name (current-buffer)))))

```

---

<div class="post-metadata">

**Author:** ![mshevchuk](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@mshevchuk](https://org-roam.discourse.group/u/mshevchuk)\
**Post date:** [April 19, 2021, 3:58pm UTC](https://org-roam.discourse.group/t/org-roam-v2-org-id-id-link-resolution-problem/1491/5 "2021-04-19T15:58:16Z")

</div>

@nobiot’s is a better approach.

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [April 19, 2021, 3:58pm UTC](https://org-roam.discourse.group/t/org-roam-v2-org-id-id-link-resolution-problem/1491/6 "2021-04-19T15:58:17Z")

</div>

@mshevchuk , @spicy @S_Fabris  
Updated [the wiki.](https://github.com/org-roam/org-roam/wiki/Hitchhiker's-Rough-Guide-to-Org-roam-V2#following-org-id-links-in-migrated-notes) Feel free to update it as you see fit, please.

---

<div class="post-metadata">

**Author:** ![S\_Fabris](https://avatars.discourse-cdn.com/v4/letter/s/a8b319/32.png) [@S\_Fabris](https://org-roam.discourse.group/u/S_Fabris)\
**Post date:** [April 20, 2021, 9:39am UTC](https://org-roam.discourse.group/t/org-roam-v2-org-id-id-link-resolution-problem/1491/7 "2021-04-20T09:39:27Z")

</div>

@nobiot

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

```

This worked. Now all IDs are cached and work independently of org-roam. This adds a second cache of all links and creates redundancy. This is good and bad at the same time: Good, because links will always work. Bad because two caches/databases need to be maintained.

I wonder if it would be faster to use the org-roam db for inter-file linking for simplicity and only fall back on org-id if the notes are used without org-roam.

---

<div class="post-metadata">

**Author:** ![mshevchuk](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@mshevchuk](https://org-roam.discourse.group/u/mshevchuk)\
**Post date:** [April 20, 2021, 10:34am UTC](https://org-roam.discourse.group/t/org-roam-v2-org-id-id-link-resolution-problem/1491/8 "2021-04-20T10:34:03Z")

</div>

> [@S\_Fabris](#):
>
> I wonder if it would be faster to use the org-roam db for inter-file linking for simplicity

This is the opposite to simplicity from the developer’s perspective. The new function is simpler than the old one and Org-roam does not have to care about how links work instead relying on the built-in mechanism, which is arguably more robust because a special effort is dedicated to it by Org maintainers. What Org-roam could do and I’m almost positive will do is provide a way to automatically update `org-id` database during initialization and whenever a note is created.

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [April 20, 2021, 12:09pm UTC](https://org-roam.discourse.group/t/org-roam-v2-org-id-id-link-resolution-problem/1491/9 "2021-04-20T12:09:15Z")

</div>

> [@mshevchuk](#):
>
> What Org-roam could do and I’m almost positive will do is provide a way to automatically update `org-id` database during initialization and whenever a note is created.

This is what V2 does from what I have seen. It uses `org-id-get-create` during the capture process, so the ID gets generated and cached in the Org-ID way.

> [@S\_Fabris](#):
>
> Bad because two caches/databases need to be maintained.

You should not have had to update the ID locations for V1 org files, because the Org-ID cache would not have been influenced by going from Org-roam V1 to V2.

The only reasons I could think of why you had to do it are:

1. You used to generate Org-ID manually, without using the `org-id-get-create` command, and other Org-ID commands.
2. You moved Org-roam files/directory outside Emacs

---

<div class="post-metadata">

**Author:** ![gcoladon](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/gcoladon/32/976_2.png) [@gcoladon](https://org-roam.discourse.group/u/gcoladon)\
**Post date:** [May 16, 2021, 5:15am UTC](https://org-roam.discourse.group/t/org-roam-v2-org-id-id-link-resolution-problem/1491/10 "2021-05-16T05:15:02Z")

</div>

> [@nobiot](#):
>
> You should not have had to update the ID locations for V1 org files, because the Org-ID cache would not have been influenced by going from Org-roam V1 to V2.
> 
> The only reasons I could think of why you had to do it are:
> 
> 1. You used to generate Org-ID manually, without using the `org-id-get-create` command, and other Org-ID commands.
> 2. You moved Org-roam files/directory outside Emacs

I’ve been trying to figure out why I’m getting errors when I run @jethro and @d12frosted 's conversion script, and after finding this thread I realize it’s because I’ve done both 1. and 2. above.

1. I have had capture templates that create file-level ID properties for while. Once I learned that org-roam v2 was going to make use of them, I started including them in all my new notes, but now I realize that org-id was unaware of them.
2. In order to achieve my desire to have some org-roam files of a non-work nature only on my personal laptop, some org-roam files of a work nature only on my work laptop, and a third category of files that are useful both at work and at home, I moved files around and into 3 different repos, thinking all I needed to do was re-synch the Roam DB and I would be good. But I guess I left org-id out of the loop, so it was missing all those changes too.

---

<div class="post-metadata">

**Author:** ![liamb](https://avatars.discourse-cdn.com/v4/letter/l/53a042/32.png) [@liamb](https://org-roam.discourse.group/u/liamb)\
**Post date:** [May 23, 2021, 10:18pm UTC](https://org-roam.discourse.group/t/org-roam-v2-org-id-id-link-resolution-problem/1491/11 "2021-05-23T22:18:32Z")

</div>

Hi All, I’m trying to follow this along and running into an error when setting the variable - `(setq org-id-extra-files (find-lisp-find-files org-roam-directory "\.org$"))` . Specifically - `(void-function find-lisp-find-files)`. Is this a known issue? Trying to find the `find-lisp-find-files` function seems to result in an error on this end, am I missing a package? Is there a way around that? I’m running Doom emacs if that helps.

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [May 24, 2021, 7:56am UTC](https://org-roam.discourse.group/t/org-roam-v2-org-id-id-link-resolution-problem/1491/12 "2021-05-24T07:56:12Z")

</div>

It’s an old [built-in library](https://github.com/emacs-mirror/emacs/blob/master/lisp/find-lisp.el) so you should have it installed in your Emacs. You can check it by looking for `find-lisp-find-dired` (it’s flagged as autoload so you can see it before loading the library).

Require or load-library `find-lisp`. You should see the function you are looking for.

Alternatively, you could try `directory-files-recursively`. Refer below.

[SlackExchange answer](https://stackoverflow.com/questions/11384516/how-to-make-all-org-files-under-a-folder-added-in-agenda-list-automatically#11384907)

> **Edit:** (2019) As mentioned in the answer by @mingwei-zhang and the comment by @xiaobing, `find-lisp-find-files` from `find-lisp` and `directory-files-recursively` also provides this functionality. However, please note in these cases the file name argument is a (greedy) regex. So something like `(directory-files-recursively "~/my-dir" "org")` will give you all Org files including backup files ( `*.org~` ). To include only `*.org` files, you may use `(directory-files-recursively "~/my-dir" "org$")` .

---

<div class="post-metadata">

**Author:** ![liamb](https://avatars.discourse-cdn.com/v4/letter/l/53a042/32.png) [@liamb](https://org-roam.discourse.group/u/liamb)\
**Post date:** [May 24, 2021, 3:24pm UTC](https://org-roam.discourse.group/t/org-roam-v2-org-id-id-link-resolution-problem/1491/13 "2021-05-24T15:24:55Z")

</div>

thank you - this worked perfectly!!

---

<div class="post-metadata">

**Author:** ![gekkostate](https://avatars.discourse-cdn.com/v4/letter/g/3d9bf3/32.png) [@gekkostate](https://org-roam.discourse.group/u/gekkostate)\
**Post date:** [December 28, 2021, 6:27pm UTC](https://org-roam.discourse.group/t/org-roam-v2-org-id-id-link-resolution-problem/1491/14 "2021-12-28T18:27:14Z")

</div>

Thanks very much for the solution, Nobiot! For those looking at this past Dec 28 2021, the function `org-roam--list-all-files` is now `org-roam-list-files`.

---

<div class="post-metadata">

**Author:** ![jes](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/jes/32/1059_2.png) [@jes](https://org-roam.discourse.group/u/jes)\
**Post date:** [January 2, 2022, 10:51am UTC](https://org-roam.discourse.group/t/org-roam-v2-org-id-id-link-resolution-problem/1491/15 "2022-01-02T10:51:49Z")

</div>

Think I had the same problem. Roam worked fine but exporting to html complained about missing IDs. Running `org-roam-update-org-id-locations` helped.

Also hi.
