reddit / emacs

How can I get org-roam unlinked references working?

modnar42 · 2022-02-03 20:04
It seems to be configured correctly, but unlinked references never show up. The [documentation](https://github.com/org-roam/org-roam/blob/master/doc/org-roam.org#configuring-what-is-displayed-in-the-buffer) explains that it's off by default, but can be enabled. I changed my configuration accordingly (use-package org-roam :custom (org-roam-directory (file-truename "~/Dropbox/OrgRoam")) (org-roam-completion-everywhere t) (org-roam-mode-section-functions (list #'org-roam-backlinks-section #'org-roam-reflinks-section #'org-roam-unlinked-references-section )) :bind ( ("C-c n f" . org-roam-node-find) ("C-c n i" . org-roam-node-insert) ("C-c n l" . org-roam-buffer-toggle) ("C-c n s" . org-roam-db-sync) ;; in case you delete a file outside emacs :map org-mode-map ("C-M-i" . completion-at-point) ) :config (org-roam-setup) (org-roam-db-autosync-mode) ) and describe-variable agrees it is configured org-roam-mode-section-functions’s value is (org-roam-backlinks-section org-roam-reflinks-section org-roam-unlinked-references-section) but that section never shows up. To test, I made nodes "Scheme", "Emacs Lisp", and "Programming Languages" that explicitly link to each other. I then made another node and wrote sentences including those titles. I tried variations on capitalizations and spacing to see if I misunderstood what would be counted as an unlinked reference. The unlinked references section has never shown up in the roam buffer. I saw that it doesn't work in windows, but I'm on mac. I saw several mentions to ripgrep, so I installed it. I tried restarting Emacs a few times, just because. I referenced [other people's configuration that have this working](https://www.alexeyshmalko.com/migrating-to-org-roam-v2/). It feels like I'm missing something obvious. Do you know what I need to do to get unlinked references to work?
ahopefullycuterrobot · 2022-02-03 22:18
Your post inspired me to actually solve this problem lol! If you are having the same problem I am having, the solution is to install a version of ripgrep with pcre2 support enabled. The v1 version of the documentation said that ripgrep with pcre2 support was needed for the unlinked references feature to work. But pcre2 is optionally when compiling ripgrep. And, unfortunately, the Debian version of the package isn't compiled with pcre2 support. There's a [bug](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=926333#14) about it. I had compiled ripgrep with prce2 support on an older machine, but I didn't use unlinked references that much and once I moved to a new OS (and Org Roam v2 came out), I never bothered to try it again. With that said, once I installed a deb of [ripgrep with pcre2 support](https://github.com/BurntSushi/ripgrep/releases), unlinked references started working! EDIT: I saw you were on mac! It's also possible something is off with your PATH (or whatever the equivalent is on mac, sorry, I've never used one!). First, check to see if your version of ripgrep has pcre2 support, by running some search with the `--pcre2` tag. If it does, see about making sure that ripgrep is on your PATH and that emacs can access it. I think [Exec Path From Shell](https://github.com/purcell/exec-path-from-shell) helps on that! If ripgrep gives you a message saying it doesn't have pcre2 support, try install and see if the executable I linked to for mac has pcre2 support. If it does, install it. Then try Emacs again. If it doesn't, try compiling it using the instructions on the ripgrep Github page. I'm not a programmer but was able to compile it well enough to work. Compiling was pretty resource intensive on my machine though!
modnar42 · 2022-02-03 23:15
Thanks for the ideas! I’ll give it a shot as soon as I can get back to my computer.
modnar42 · 2022-02-04 03:00
Yep, it was the Emacs path variable and Exec Path From Shell fixed it. Thanks for taking the time u/ahopefullycuterrobot! ​ For anyone looking at this in the future that might want detailed information about what I did, I ran rg -pcre2 foo in my normal shell, then ran the same command in eshell in my emacs instance (M-x eshell) and got rg: command not found Back in my normal terminal, I checked where rg is installed with # which rg /usr/local/bin/rg then checked the state of my Emacs path variables in eshell $ echo $PATH /usr/bin:/bin:/usr/sbin:/sbin:/Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_14:/Applications/Emacs.app/Contents/MacOS/libexec-x86_64-10_14 and, lo and behold, /usr/local/bin isn't in my path in Emacs. I installed the suggested library ;; NOTE: this isn't exactly how this package says to initialize it ;; I just did it this way to test it quickly (use-package exec-path-from-shell :init (exec-path-from-shell-initialize)) and tried to run the above ripgrep command again. It worked, so I checked my org-roam buffer and found my unlinked references. Hooray!
ahopefullycuterrobot · 2022-02-04 11:43
Awesome! I'm a bit amused that the mac version of ripgrep has pcre2 support built-in, while the debian version doesn't though. Glad my tangential edit was actually useful though! I'll note for future readers that you can edit the exec path in Emacs (through Customize) and could also symlink the rg binary to something on Emacs' exec path, but I had so many problems with that I gave up and used exec-path-from-shell.