jkitchin / org-ref

org-mode modules for citations, cross-references, bibliographies in org-mode and useful bibtex tools to go with it.
GNU General Public License v3.0
1.35k stars 242 forks source link

cannot require org-ref #1105

Closed japhir closed 5 months ago

japhir commented 5 months ago

Hi John! I've been running into this issue lately: Debugger entered--Lisp error: (void-variable org-ref-citation-hydra)

There were many ways in which this triggered, but the easiest I could find after installing the package with this in the folder name: 20240129.1719 was to just (require 'org-ref) in *scratch*.

Debugger entered--Lisp error: (void-variable org-ref-citation-hydra)
  byte-code("\305\10\306\307\310\11\311\312\313$$\210\305\10\306\314\315\n\316\312\313$$\210\305\10\306\317\320\13\321\312\313$$\210\305\10\306\322\323\f\324\312\313$$\207" [org-ref-citation-hydra oa-open oa-related-works oa-cited-by-works oa-referenced-works defhydra+ nil "Add open from action to `org-ref-citation-hydra'." "xa" "Open in OpenAlex" :column "OpenAlex" "Add related documents action to `org-ref-citation-hydra'." "xr" "Related documents" "Add cited by documents action to `org-ref-citation-hydra'." "xc" "Cited by documents" "Add references from action to `org-ref-citation-hydra'." "xf" "References from"] 9)
  require(openalex)
  byte-code("\305\306!\210\305\307!\210\310\20\311\21\312\22\313\23\314\24\315\316!\207" [org-ref-insert-link-function org-ref-insert-cite-function org-ref-insert-label-function org-ref-insert-ref-function org-ref-cite-onclick-function require org-ref-core openalex org-ref-insert-link org-ref-insert-cite-link org-ref-insert-label-link org-ref-insert-ref-link #f(compiled-function (_) #<bytecode -0x14378595798c0ca6>) provide org-ref] 2)
  require(org-ref)
  (progn (require 'org-ref))
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  command-execute(eval-last-sexp)
japhir commented 5 months ago

Might be related to https://github.com/jkitchin/org-ref/issues/822 ?

japhir commented 5 months ago

Actually, it's related to https://github.com/jkitchin/org-ref/issues/1085! Commenting out the (require 'openalex) line in org-ref fixes the issue!

jkitchin commented 5 months ago

this seems pretty weird. org-ref-citation-hydra is defined in org-ref-citation-links, which is loaded in org-ref-core, so that should be ok I think.

I added two commits that might help with the issue.

japhir commented 5 months ago

Nice, these do resolve the issue! I don't know what's happening behind the scenes, but I spent entirely too much time this morning trying to figure out where this error slipped in so I'll just take your fix and stop thinking about it ;-).

Thank you!

sents commented 5 months ago

I'm on b1ceadaa5eaa253e9dac223b9f23ce2b4e8e8ab7 and the issue is still present for me.

jkitchin commented 5 months ago

If you open org-ref.el and run M-x eval-buffer do you still get the error?

If not, try running this and make sure it points to the git repo, and not to something installed from Melpa:

#+BEGIN_SRC emacs-lisp
(locate-library "org-ref")
#+END_SRC
pradyparanjpe commented 4 months ago

org-ref compilation (still) throws the following error:

openalex.el:566:2: Error: Symbol’s value as variable is void: org-ref-citation-hydra/params

despite the function declaration inserted by commit 26d5b2f

(declare-function org-ref-citation-hydra "org-ref-citation-links")

Require

(Re) Compilation throws no error upon addition of

(require 'org-ref-citation-links)

... and then, everything works well.

This is just an observation, I don't know how / why. (I see that openalex is 'required' in org-ref-core after org-ref-citation-links already.)

Naïve question

Is this because openalex's native compilation gets triggerred during package installation before and without the need for it to be 'required'? Because looking at compilation warnings, it appears so. Warnings from openalex start in my *compilation* buffer at line 13, while those from org-ref-citation-links start at 701.

jkitchin commented 4 months ago

I pushed that require. I don't see any downside to it, and if it fixes the problem all the better.