org-roam / org-roam-bibtex

Org Roam integration with bibliography management software
GNU General Public License v3.0
571 stars 47 forks source link

`user-error: No #+ROAM_KEY found in current buffer` #127

Closed junwei-wang closed 3 years ago

junwei-wang commented 3 years ago

ORB Note Action does not work on macOS Big Sur + Doom Emacs. The mini buffer says user-error: No #+ROAM_KEY found in current buffer.

Example file:

#+TITLE: Computing aggregation function minimum/maximum using homomorphic encryption schemes in wireless sensor networks (WSNs)
#+ROAM_KEY: cite:ICWN:ErtaulK07
#+ROAM_TAGS: crypto fhe
myshevchuk commented 3 years ago

Hi, I'm on Big Sur + Doom and cannot reproduce your issue. Everything's working perfectly fine. I will need more specific information, e.g. the BibTeX entry, the exact commands you run, the org-roam-bibtex and org-roam commits you are at and so on.

junwei-wang commented 3 years ago
myshevchuk commented 3 years ago

I still cannot reproduce this with your entry.

Screenshot 2020-12-03 at 09 41 22

There were some issues about #ROAM_KEY: recently as far as I remember. So if anything, it's most probably related to Org Roam, not ORB. Did you try to rebuild your Org Roam database, M-x org-roam-db-build-cache?

A bug trace would be very helpful. Turn on toggle-debug-on-error and try running the command again.

junwei-wang commented 3 years ago

Hi, thank you very much for your instant reply.

myshevchuk commented 3 years ago

Try purging Org, Org Roam and ORB from $DOOM/.local/straight/build-xx.x/. Quit Emacs and run doom sync. As a last resort, try purging the whole directory $DOOM/.local/straight/build-xx.x/.

junwei-wang commented 3 years ago

I tried to rebuild doom and tried to restart my computer, the issue still exists.

Thank you very much anyway.

junwei-wang commented 3 years ago

BTW, I paste my Doom package.el:

;;; org-roam
;;; org-roam-bibtex
(package! org-roam-bibtex
  :recipe (:host github :repo "org-roam/org-roam-bibtex"))
;; When using org-roam via the `+roam` flag
(unpin! org-roam company-org-roam)

;;; org-roam-server
(package! org-roam-server)

;;;
(package! helm-bibtex)
myshevchuk commented 3 years ago

The error is indeed emanated by orb-note-actions when the citation key is nil. This function relies on org-roam--extract-refs to extract the value of the citekey from #+ROAM_KEY: citekey. For some reason, org-roam--extract-refs is not working properly in your environment. By expecting its code, I would say this function will return nil when the cite:-type org-links are not defined. These citation links are defined by the package org-ref. Is it possible that you do not have org-ref installed on your computer, or that it is not (properly) loaded during the run time?

junwei-wang commented 3 years ago

Yes, you are right. Thank you very much. Sorry for this stupid mistake.

For new users encountering same issue, here is my package.el

;;;;;;;;; org-roam-bibtex (ORB)
(package! org-roam-bibtex
  :recipe (:host github :repo "org-roam/org-roam-bibtex"))
;; When using org-roam via the `+roam` flag
(unpin! org-roam company-org-roam)

;;; ORB dependencies
(package! org-ref)
(package! helm-bibtex)

and config.el

;;;;;;;;; Bibliography
;;; helm-bibtex
(setq bibtex-completion-bibliography '("/path/to/your_first.bib"
                                       "/path/to/2nd.bib")
      bibtex-completion-library-path '("/path/to/pdfs"))

;;; org-ref
(setq reftex-default-bibliography bibtex-completion-bibliography)

;; see org-ref for use of these variables
(setq org-ref-default-bibliography bibtex-completion-bibliography
      org-ref-pdf-directory "/path/to/pdfs")
junwei-wang commented 3 years ago

Something irrelevant:

How to add note directly in pdf as in https://youtu.be/Wy9WvF5gWYg?t=380. What command / key-binding was used in the video?

myshevchuk commented 3 years ago

It's perfectly fine to be a beginner. Also, org-roam-bibtex softly depends on org-ref, and I believe this is not stated in the README. I will also improve the error message, because it did not reflect what was going on, which may be considered a bug. So thank you and I'm glad you've solved your issue.

It is a different kind of notes in the video. The package is called org-noter. It is not affiliated with ORB, but ORB offers minimal integration with it. So these are org-noter notes as headlines inside a org-roam(-bibtex) note.

junwei-wang commented 3 years ago

Thank you for you kind reply. I find this package and enjoy using it now.