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.36k stars 242 forks source link

Following org-ref link gives "org-ref-cite-candidates: Wrong type argument: stringp, nil" #757

Closed C-J-Cundy closed 3 years ago

C-J-Cundy commented 4 years ago

I'm having an issue when I use C-c C-o while the cursor is on an org-ref link. Inserting cite links goes fine, but I can't seem to follow the inserted links. If the cursor is in the middle of the link I get "org-ref-cite-candidates: Wrong type argument: stringp, nil". In the messages buffer it also prints the reference I'm trying to go to.

I can replicate this with a very simple .bib file and .emacs file, shown below.

bugreport

Any idea what the issue is?

jkitchin commented 4 years ago

I can confirm this is a problem. The issue seems to be org-link-open-from-string which inserts a copy of the cite link in a temp buffer. then, there is a fontification error when it switches that buffer to org-mode. That is probably a bug in org-ref, but not one I can track down right now.

You don't really "follow" a cite link in the usual sense. you should be able to press Enter on a link to activate a menu of actions that enable a lot of different things to happen.

tim-hilt commented 3 years ago

Any progress on this? I'm having the same issue.

When i set

(use-package! org-ref
  :after org-roam
  :init
  (setq org-ref-completion-library 'org-ref-ivy-cite)
  ...

i have a menu when clicking on a cite-link, but now i can't insert a cite-link with C-c ] anymore. It just shows an empty ivy-window with prompt "Open: "

tim-hilt commented 3 years ago

Update: When setting org-ref-default-bibliography '("~/Hahn-Schickard/Bachelorarbeit/Arbeit/library.bib") it works! The variable should be a list instead of a string!

jkitchin commented 3 years ago

Thanks for the update!

jkitchin commented 3 years ago

I can confirm this is a problem. The issue seems to be org-link-open-from-string which inserts a copy of the cite link in a temp buffer. then, there is a fontification error when it switches that buffer to org-mode. That is probably a bug in org-ref, but not one I can track down right now.

You don't really "follow" a cite link in the usual sense. you should be able to press Enter on a link to activate a menu of actions that enable a lot of different things to happen.

Is this just a problem when the cite link is at the beginning of the buffer? i.e. does it happen in other places?

gelbwald commented 3 years ago

I'm having the same issue.

Update: When setting org-ref-default-bibliography '("~/Hahn-Schickard/Bachelorarbeit/Arbeit/library.bib") it works! The variable should be a list instead of a string!

This didn't work for me.

Is this just a problem when the cite link is at the beginning of the buffer? i.e. does it happen in other places?

For me it happens regardless of whether the link is at the beginning of the buffer.

Interestingly, I use a custom function for opening pdfs. I.e. I have (setq org-ref-open-pdf-function 'my/org-ref-open-pdf-at-point). The error happens apparently before this function gets called.

cvanelteren commented 3 years ago

Update: When setting org-ref-default-bibliography '("~/Hahn-Schickard/Bachelorarbeit/Arbeit/library.bib") it works! The variable should be a list instead of a string!

This also didn't work for me. I am still getting that org cannot find the reference even after setting the global var and adding BIBLIOGRAPHY property

alcinos commented 3 years ago

Hello,

Not sure it's exactly the problem that caused the symptoms in OP, but I get the same error when some specific conditions are met in the bib file. I haven't dug very deep, but for example:

@inproceedings{maAdequacyUntunedWarmup2019,
  title = {On the Adequacy of Untuned Warmup for Adaptive Optimization},
  author = {Ma, Jerry and Yarats, Denis}
}

works, but changing the citation type to "online" breaks it:

@online{maAdequacyUntunedWarmup2019,
  title = {On the Adequacy of Untuned Warmup for Adaptive Optimization},
  author = {Ma, Jerry and Yarats, Denis}
}

using @article as in OP works, but maybe some other part of the bibliographic entry is tripping the parser?

Hope this help nailing the root cause.

jkitchin commented 3 years ago

I am pretty sure online is not a supported bibtex type. org-ref uses the bibtex in emacs to parse this, and it only recognizes the official types.

It might be a biblatex type, in which case you need to be sure you set that as the dialect in the bibtex file.

I think you can find some information at https://github.com/jkitchin/org-ref/issues/482 on how to add a custom type that should be recognized by org-ref.

TS-CUBED commented 3 years ago

Hello, I seem to have a related problem here. I cannot use "thesis" type bibtex entries.

The entry in question looks like this:

@phdthesis{Burgin2018, title = {Development of Explicit and Constitutive Lattice-Boltzmann Models for Food Product Rheology}, author = {Burgin, Kallum}, year = {2018}, address = {{Sheffield}}, school = {Sheffield Hallam University}, type = {Doctoral {{Thesis}}} }

Changing it to @article makes it work, @report does not.

BTW, the export to LaTeX does work, nonethelee, while the export to HTML doesn't

jkitchin commented 3 years ago

PhDThesis is not a recognized bibtex type, so that entry will not be parsed by bibtex. For me it should be @Thesis. I am surprised @report doesn't work. @Report is defined as a type in bibtex, and I would have thought it was not case-sensitive.

The only backend that supports all types is Latex, and that is done via bibtex/biblatex, i.e. an external citation formatter. For other backends, you may have to define how to export them yourself. I think this is done in org-ref-bibliography-entry-format, where you would need to add how you want a thesis to be formatted.

TS-CUBED commented 3 years ago

Thanks for the quick reply.

The variable =org-ref-bibliography-entry-format=

was set to

+begin_src emacs-lisp

(("article" . "%a, %t, %j, %v(%n), %p (%y). <a href=\"%U\">link. <a href=\"http://dx.doi.org/%D\">doi.") ("book" . "%a, %t, %u (%y).") ("techreport" . "%a, %t, %i, %u (%y).") ("proceedings" . "%e, %t in %S, %u (%y).") ("inproceedings" . "%a, %t, %p, in %b, edited by %e, %u (%y)"))

+end_src

so =@report= wasn not included as well.

Adding a

=(add-to-list 'org-ref-bibliography-entry-format '("phdthesis" . "%a, %t, (%y)."))=

to my config does change the variable, but does not change the behaviour. I changed the format to the simplest possible one so there wouldn't be any missing fields.

John Kitchin notifications@github.com writes:

CAUTION: This message was sent from outside the University, purportedly from noreply@github.com .

Please check the sender is legitimate before responding. Please treat any links or attachments with care - do not follow or open them unless you are sure they are genuine.

PhDThesis is not a recognized bibtex type, so that entry will not be parsed by bibtex. For me it should be @Thesis. I am surprised @report doesn't work. @Report is defined as a type in bibtex, and I would have thought it was not case-sensitive.

The only backend that supports all types is Latex, and that is done via bibtex/biblatex, i.e. an external citation formatter. For other backends, you may have to define how to export them yourself. I think this is done in org-ref-bibliography-entry-format, where you would need to add how you want a thesis to be formatted.

--

Dr. Torsten Schenkel \ Dr.-Ing. habil. CEng FIMechE

Associate Professor of Continuum Mechanics

Sheffield Hallam University \ Department of Engineering and Mathematics \ College of Business, Technology and Engineering \ Room 4206, Sheaf Building

Sheffield, S1 1WB \ UK

Tel +44 (0)114 225 6294 \ WEB https://www.shu.ac.uk/about-us/our-people/staff-profiles/torsten-schenkel \ EC2M3 https://blogs.shu.ac/ecm \ github: TS-CUBED - https://ts-cubed.github.io/

jkitchin commented 3 years ago

Something is not adding up.

This org file:

* Following org-ref link gives "org-ref-cite-candidates: Wrong type argument: stringp, nil" #757

here is the cite cite:Burgin2018.

bibliography:test.bib

With this bib file:

@PhDThesis{Burgin2018,
title = {Development of Explicit and Constitutive Lattice-Boltzmann Models for Food Product Rheology},
author = {Burgin, Kallum},
year = {2018},
address = {{Sheffield}},
school = {Sheffield Hallam University},
type = {Doctoral {{Thesis}}}
}

gives me this html

image

Note it does not work for pdf because PhDThesis is not a valid bibtex entry as I mentioned earlier.

The image above shows the bibtex entry as the bibliography, which is not great.

If I run your add-to-list code, then I get the following output for html:

image

TS-CUBED commented 3 years ago

Hi John,

thanks, so there seems to be something different in my config. I can get the reference to work with type @thesis but not with @phdthesis.

If I use @thesis then I get the bibtex entry as in your first example. Then I can add the thesis format (with the add-to-list command above) and I can then get a properly formatted reference.

However it does not work with @phdthesis.

It also doesn't open the org-ref(?) menu (0 Open bibtex entry, 1 Quit, 2 Try to get PDF ...) if the type is @phdthesis.

Where is it defined which types get recognised as valid bibtex entries?

Funny enough it worked for pdf the whole time for me, even before defining the org-reg-bibliography-entry-type

Easiest solution for the immediate problem for me is to simple put my bibtex file through sed after I export it from Zotero (Zotero defaults to the phdthesis type. Why does Zotero use a nonstandard type here?), but that will break the auto-update.

jkitchin commented 3 years ago

you can find the known types with (assuming you use 'bibtex as the dialect, biblatex would have others defined.):

+BEGIN_SRC emacs-lisp

(mapcar 'car bibtex-biblatex-entry-alist)

+END_SRC

+RESULTS:

| Article | Book | MVBook | InBook | BookInBook | SuppBook | Booklet | Collection | MVCollection | InCollection | SuppCollection | Manual | Misc | Online | Patent | Periodical | SuppPeriodical | Proceedings | MVProceedings | InProceedings | Reference | MVReference | InReference | Report |

org-ref relies on bibtex to parse entries, so if bibtex doesn't recognize it, neither will org-ref (most likely). In your case, @phdthesis is not a bibtex type, which is the issue. I don't know if it is a supported biblatex type or not.

TS-CUBED commented 3 years ago

Getting closer :-)

So it seems the problem is with Zotero. It insisists of using phdthesis instead of thesis in both the native and the better-bibtex exports. Interestingly, it does switch it to thesis when I select biblatex for the export dialect/format.

Thanks for the help and all the effort you put into the scientific writing capability of emacs/org-mode. My config is based on doom, but I borrow heavily from your work.

schlagenhauf commented 3 years ago

I had the same issues with citations of @online entries. Like @TS-CUBED i'm using Zotero + BetterBibtex plugin. I fixed the issue by selecting "Better BibTex" instead of "Better BibLaTex" when selecting an export file. Former @online entries are now under @misc or @article, depending on the source.