Org-roam: Confusion around file names and creating existing links

Created on 17 Feb 2020  路  6Comments  路  Source: org-roam/org-roam

Hi!

Thank you so much for creating this. I'm in the process of emptying my org-brain repository and entering the information in here -- which is a much better fit for how I want to be able to think.

Something just happened, which I think is related to the default behavior of using timestamps for file names (or may be a bug in the background updater - I don't quite know how to troubleshoot the current state of things):

  1. I created an org-roam file with org-roam-find-file for a link about how to handle projects in org-mode.
  2. In that file, I pasted the link, I also used org-roam-insert-file to insert a link to a non-existing roam file called "org-mode".
  3. I then used org-roam-find-file to open the file org-mode, which _created a new file_ when my intent was to open the file I had just created with that name.

I'm not exactly sure what happened, but my intent was to have a single file with the name org-mode.

bug prioritp0

All 6 comments

I suppose the only relevant steps here are steps 2 and 3? You're saying you're seeing behaviour where:

  1. org-roam-insert is used to create a new file with title "org-mode", but
  2. org-roam-find-file after that creates another new file?

I cannot yet replicate this behaviour on my end.

I'm experiencing a similar issue which might be the same bug. Here's the behavior I'm seeing:

  1. Use org-roam-insert to create a new file with title "debug test". This correctly creates a file titled "debug test" with filename "20200216235558" from the timestamp.
  2. Use org-roam-find-file to try to find "debug test". Here I expect to see debug test. However, I cannot find it. Instead, I am only able to find the automatically generated timestamp filename "20200216235558". Since I am unable to find "debug test", I create another file also titled "debug test" (with true filename generated as "20200217000332").

In this first screenshot, notice that despite being in the file titled "debug trace", org-roam-find-file cannot find anything for the query "debug trace"
Screen Shot 2020-02-17 at 12 08 33 AM

In this second screenshot, notice that I am able to find the file by its true file name "20200216235558".
Screen Shot 2020-02-17 at 12 09 26 AM

Now here's where things get weird. After I restart emacs, I can suddenly org-roam-find-file my created files by title again. This third screenshot is the result of org-roam-find-file after restarting - I can now find "debug test", both "20200216235558" and "20200217000332".
Screen Shot 2020-02-17 at 12 12 35 AM

EDIT: just for completeness sake, confirmed that after restarting emacs, trying to find the file by searching for "20200216235558" now doesn't turn up anything, it can only be found by querying for its title "debug trace" as expected

Okay, it seems like the cache isn't updated on insert for both of you. Can you load emacs, evaluate this function and see if the behaviour is different:

(defun org-roam--make-file (file-path &optional title)
  "Create an org-roam file at FILE-PATH, optionally setting the TITLE attribute."
  (if (file-exists-p file-path)
      (error (format "Aborting, file already exists at %s" file-path))
    (if org-roam-autopopulate-title
        (org-roam--populate-title file-path title)
      (make-empty-file file-path))
    (save-window-excursion
      (with-current-buffer (find-file file-path)
        (org-roam--update-cache)
        ))))

Yup, it works now

Also, without that change, can you M-x toggle-debug-on-error and also check your messages buffer for any errors?

And what version of Emacs are you on? I don't know why it's only necessary for you both.

Re-executed above steps without the change with debug-on-error enabled. Never entered the debugger, and messages buffer doesn't have any errors. I'm on GNU Emacs 26.3 from the mac homebrew emacs-plus formula

Was this page helpful?
0 / 5 - 0 ratings

Related issues

progfolio picture progfolio  路  3Comments

grzm picture grzm  路  4Comments

nmartin84 picture nmartin84  路  3Comments

Donkeyfish87 picture Donkeyfish87  路  4Comments

jason-morgan picture jason-morgan  路  5Comments