Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

citr crashes connecting to Zotero library #74

Open
earcanal opened this issue Oct 14, 2020 · 11 comments
Open

citr crashes connecting to Zotero library #74

earcanal opened this issue Oct 14, 2020 · 11 comments

Comments

@earcanal
Copy link

Describe the bug

citr crashes when connecting to Zotero library.

To Reproduce

  1. Click Connect and load libraries, next to Zotero connection available.

Console displays error message below, and R Studio requires a restart to prevent this error when accessing citr.

> citr:::insert_citation()

Unsaved R Markdown document: Cannot locate bibliography files;
         falling back to manual path specification.


Listening on http://127.0.0.1:5619
Warning in do_read_bib(file, encoding = .Encoding, srcfile) :
  
Mtvgyl61J71EobVglxMuYlmwMCnmKQI6.bib:2:0
	syntax error, unexpected $end
	Dropping the entry `Lottridge2012` (starting at line 55) 
Warning: Error in do_read_bib: unprotect_ptr: pointer not found
  70: do_read_bib
  69: RefManageR::ReadBib
  68: import_bbt
  67: load_betterbiblatex_bib
  63: <reactive>
  47: bibliography
  46: <observer>
   3: shiny::runApp
   2: runGadget
   1: citr:::insert_citation
Warning: Error in do_read_bib: unprotect_ptr: pointer not found
  49: <Anonymous>
Warning: Error in do_read_bib: unprotect_ptr: pointer not found

Expected behavior

Able to cite items in Zotero library.

Screenshots

citr

@earcanal
Copy link
Author

This looks like a dup of #71, and could be an instance of a known issue. I get a similar error (with a different key) after adding 'abstract' to Fields to omit from export in Better BibTeX config.

> citr:::insert_citation()

Listening on http://127.0.0.1:4729
Warning in do_read_bib(file, encoding = .Encoding, srcfile) :
  
qRaBLTQp0Bfju6Mu3eSCYfvRYQgb65CT.bib:2:0
	syntax error, unexpected $end
	Dropping the entry `baer2019` (starting at line 2373) 
Warning: Error in do_read_bib: unprotect_ptr: pointer not found
  70: do_read_bib
  69: RefManageR::ReadBib
  68: import_bbt
  67: load_betterbiblatex_bib
  63: <reactive>
  47: bibliography
  46: <observer>
   3: shiny::runApp
   2: runGadget
   1: citr:::insert_citation
Warning: Error in do_read_bib: unprotect_ptr: pointer not found
  49: <Anonymous>
Warning: Error in do_read_bib: unprotect_ptr: pointer not found
  106: <Anonymous>

@earcanal
Copy link
Author

Fields to omit from export = abstract,notes doesn't resolve the issue.

I've established that the citation key in the syntax error message is the last one in the configured .bib, regardless of how many entries there are in that file. If it's empty, it says null. I suspect this error is a red herring.

I wonder if there's a memory overflow due to the size of my Zotero libraries. If I've counted correctly, the total number of items in my libraries is just over 4,000. You could test this hypothesis by starting with a library size that doesn't produce the error, then repeatedly duplicating all of the items, to see if you can reproduce it.

@earcanal
Copy link
Author

Hmm, I didn't think I'd made any changes, but citr can now load the Zotero libraries! So it looks like omitting abstract,notes resolved this for me.

However, I still have some errors, and citr can't find the item in a Zotero library that I want to cite:

> citr:::insert_citation()

Listening on http://127.0.0.1:7262
Warning in do_read_bib(file, encoding = .Encoding, srcfile) :
  
uYOdyFJIkKBEZDxxnDqKsPdqGEwFbkUU.bib:27507:0
	syntax error, unexpected TOKEN_AT, expecting TOKEN_COMMA or TOKEN_RBRACE
	Dropping the entry `spitzerrlBriefMeasureAssessing2006` (starting at line 27488) 
Ignoring entry ‘buehlerPlanningFallacyCauses2002’ (line3865) because: 
	The name list field author cannot be parsed

Warning in do_read_bib(file, encoding = .Encoding, srcfile) :
  
johR9DIacJyuQ9n1FB8hCjTBrEzbEoYD.bib:9:1
	syntax error, unexpected TOKEN_VALUE, expecting TOKEN_LBRACE
	Dropping the entry `spitzerrlBriefMeasureAssessing2006` (starting at line 27488) 
Warning in do_read_bib(file, encoding = .Encoding, srcfile) :
  
ly3yjrICAfFABmfAON2B63uBUQYaMEXj.bib:5:1
	syntax error, unexpected TOKEN_VALUE, expecting TOKEN_LBRACE
	Dropping the entry `spitzerrlBriefMeasureAssessing2006` (starting at line 27488) 
Warning in do_read_bib(file, encoding = .Encoding, srcfile) :
  
PHBCMemrIp1bPQeQ9HUyshFYyOyFUBqx.bib:7:1
	syntax error, unexpected TOKEN_VALUE, expecting TOKEN_LBRACE
	Dropping the entry `spitzerrlBriefMeasureAssessing2006` (starting at line 27488) 
Warning: stack imbalance in '<-', 301 then 315
Warning: stack imbalance in '{', 297 then 311
Warning: stack imbalance in '{', 287 then 301
Warning: stack imbalance in 'if', 285 then 299
Warning: stack imbalance in '{', 281 then 295
Warning: stack imbalance in 'if', 279 then 293
Warning: stack imbalance in '{', 275 then 289
Warning: stack imbalance in 'if', 273 then 287
Warning: stack imbalance in '{', 269 then 283
Warning: stack imbalance in 'if', 260 then 274
Warning: stack imbalance in '{', 256 then 270
Warning: stack imbalance in 'withVisible', 250 then 264
Warning: stack imbalance in '{', 244 then 258
Warning: stack imbalance in '<-', 238 then 252
Warning: stack imbalance in '{', 234 then 248
Warning: stack imbalance in '{', 227 then 241
Warning: stack imbalance in '{', 220 then 234
Warning: stack imbalance in '{', 206 then 220
Warning: stack imbalance in '{', 196 then 210
Warning: stack imbalance in '{', 189 then 203
Warning: stack imbalance in '{', 178 then 192
Warning: stack imbalance in 'if', 176 then 190
Warning: stack imbalance in '{', 172 then 186
Warning: stack imbalance in 'names', 168 then 182
Warning: stack imbalance in '<-', 166 then 180
Warning: stack imbalance in '{', 162 then 176
Warning: stack imbalance in 'if', 153 then 167
Warning: stack imbalance in '{', 149 then 163
Warning: stack imbalance in '{', 142 then 156
Warning: stack imbalance in '{', 135 then 149
Warning: stack imbalance in '{', 121 then 135
Warning: stack imbalance in '{', 111 then 125
Warning: stack imbalance in '{', 104 then 118
Warning: stack imbalance in '{', 83 then 97
Warning: stack imbalance in 'if', 81 then 95
Warning: stack imbalance in '{', 77 then 91
Warning: stack imbalance in 'withVisible', 71 then 85

@earcanal
Copy link
Author

Mystically, after another R Studio restart, that error goes away too, and I can cite the item I wanted! So this is resolved, I'm just not sure how!

@crsh
Copy link
Owner

crsh commented Oct 15, 2020

Thanks for reaching out and reporting on your progress. I'm not sure exactly what went wrong here, but omitting abstract and note and restarting the R session once you encounter such errors has helped to fix these types of errors before. I have been unsatisfied with the approach to interface with Zotero, so I've been looking for an alternative. But seeing that the next RStudio release will feature a visual editor for R Markdown that comes with a built-in citation feature and connects to Zotero, I may halt development on citr (unless it get's picked up by VSCode users).

@earcanal
Copy link
Author

Please don't give up yet! I came back to citr after deciding that the visual editor isn't production quality yet. Notably inserting square brackets around citations is a showstopper. Also, I prefer writing in markdown, and although good, the citation features are only available in the visual editor.

@crsh
Copy link
Owner

crsh commented Oct 15, 2020

Thanks for the feedback. I'll keep an open mind about it.

@earcanal
Copy link
Author

I'm reopening this, as the behaviour is intermittent. When it works, the connection to Zotero is made when you first open citr. If that doesn't happen and you have to click Connect and load libraries, then it triggers the bug.

I can't explain why the connection to Zotero is intermittently made when opening citr.

@earcanal earcanal reopened this Oct 15, 2020
@ShixiangWang
Copy link

Still crash with the latest version from GitHub, any updates?

@krzyklo
Copy link

krzyklo commented Nov 5, 2021

I have also R Studio crash, when trying to link and connect Zotero library.

citr:::insert_citation()

Listening on http://127.0.0.1:7856
Warning: Error in bibtex::do_read_bib: lex fatal error:
fatal flex scanner internal error--end of buffer missed

70: bibtex::do_read_bib
69: RefManageR::ReadBib
68: import_bbt
67: load_betterbiblatex_bib
63:
47: bibliography
46:
3: shiny::runApp
2: runGadget
1: citr:::insert_citation
Warning: Error in bibtex::do_read_bib: lex fatal error:
fatal flex scanner internal error--end of buffer missed

49:
Warning: Error in bibtex::do_read_bib: lex fatal error:
fatal flex scanner internal error--end of buffer missed

106:

@krzyklo
Copy link

krzyklo commented Nov 5, 2021

Though, I could export whole database to BIB file with Zotero -> Preferences -> Automatic export to File.

Then could manually put references into Rmd documents, which are found when Knitting.
This basicly bypass, CITR completely.

KK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants