Parsing of tmp buffers(?) breaks relative include handling

I have a setup.org file which I include in my notes files with #+setupfile: setup.org. This file lives in my root roam directory, and in subdirectories I include it with #+setupfile: ../setup.org. This works fine in normal operation.

Currently db builds don’t work, and I believe it is because. I believe it copies the contents of files to a tmp buffer without setting the current directory. This means that the relative link is no longer correct. At first glance I think it is working for base #+setupfile: setup.org includes (not sure thout)

I haven’t dived into the code yet or properly debugged, but some things I need to test are:

  • Does it work for #+setupfile: setup.org for notes in my base roam directory
  • Does it work if I specify the absolute path. (I don’t want to do this as a long-term solution as this path isn’t the same on all my machines
  • Investigate how parsing of files works and how it switches directories and manages tmp buffers etc.
  • I noticed that there have been several PRs merged modifying how updates are handled so I might do a bisect to see where this occured.

I suspect this could be fixed by changing the current working directory when parsing tmp buffers, but I’ll need to dive in.

Has anyone else had an issue similar to this? My current workaround is to copy setup.org into each of my subdirectories, and this seems to be working ok.

I used to have relative links in #+setupfile: for a long time. The Org-roam database built fine but during interactive capture sessions I always had warnings, something like “could not find setup file” emanated by Org-mode in temporary capture buffers. It annoyed me a lot and I switched to absolute paths perhaps a month ago. So the behaviour you describe has probably been introduced relatively recently.

By the way, I’d argue you, you can have different file paths on different machines and still be able to use absolute file paths everywhere in Emacs. By means of symlinks.

Machine A: /absolute/path-A/to/my/files/
Machine B: /absolute/path-B/to/my/files/

On both machines create symbolic links /my/symlink/path/to/my/files/ pointing to the respective locations, and use the symlink paths in your config and Org-mode files. This may require patience because you’ll need to figure packages or parts of your Emacs config which need real paths and adjust the respective bits with file-truename or directory-abbrev-alist. In most situations this won’t be necessary though. This is just a suggestion, I haven’t tried such a setup across different machines. On the other hand, I heavily rely on symbolic links, org-directory including, on my single computer and they seem to work so far.

I got https://github.com/org-roam/org-roam/pull/1300 merged which sets the value of default-directory on org roam temp buffers. This should allow relative links to be not broken