Closed polc1410 closed 5 years ago
Thanks for the detailed report, I'll try to look into this as soon as possible.
Small update.
I've developed a workaround. But its not perfect. Considering that this is RStudioServer the running of a ZoteroStandalone Application is not particularly likely to be a common use. So perhaps there is more that could be done with my solution to make it elegant!
# Connect to ZoteroBibliography Manager
require(RefManageR)
require(bibtex)
require(tidyverse)
# Login to your Zotero Web Account
#
# Visit: https://www.zotero.org/settings/keys
# Above the link to create a new API key copy the Your userID for use in API calls is XXXXXX
# copy they key below
#
zoteroUserKey = "XXXXXX"
# Create a new access key (click the link)
# copy the access key below
#
zoteroAccessKey = "YYYYYYYYYY"
# Navigate to the Library or Collection you want to use for referencing.
# e.g. https://www.zotero.org/yourusername/items/collectionKey/ZZZZZZZZ
#
zoteroCollection="ZZZZZZZZ"
# Download a bib file from zotero server
zotero <- ReadZotero(
user = zoteroUserKey,
.params = list(
collection = zoteroCollection,
key = zoteroAccessKey
)
)
# Setup the Bibliography style
#
BibOptions(bib.style="numeric")
# Build a data frame to find the references easier
# This will allow you to view the reference's short names.
# by looking at a data frame called 'refs' and copying the 'key' for the relevant
# title.
refs <- zotero %>% {
.$title
} %>%
bind_rows() %>%
gather(key = 'key', value = 'title', 1:length(zotero))
# Now write a file containing the bibliography to the current working
# directory. File will be called 'reference.bib'
#
# And add the following entry (without the # marks) to the YAML header
# ---
# bibliography: reference.bib
# ---
write.bib(zotero, 'reference.bib')
# You can now use [@citation_key_2000] to cite your articles
# in your markdown.
# Not as simple as using citr directly, but does work on zotero
# and stays up to date as you update your zotero and re-run the code
#
ideally we might get citr to read the reference.bib file but produce the pop-up and allow you to select the reference - avoiding the refs<- section in the code and manual copy & paste, and easier article searching etc.
So I've been partially able to reproduce the problem. When the focus is on the R Markdown file, it detects the file, but can't load it. When the focus is in the console, the addin resorts back to manual path specification (the error message is somewhat misleading; this is also happens when the focus isn't on an R Markdown file). In this case, the addin successfully reads the file and I can search the references. However, this only works until I first try it with the focus on the R Markdown file (after that I have to restart my R session to be able to read the file). Could you confirm that the last bit is true in your case as well?
Also a quick questions regarding the failing Zotero connection (I don't have Zotero on my RStudio server right now): The missing encoding
is a little surprising because it should be taken from the global options. Could you try to reproduce that error and then report the output of getOption("citr.encoding")
?
> require(citr)
Loading required package: citr
> getOption("citr.encoding")
[1] "UTF-8"
So I've been partially able to reproduce the problem. When the focus is on the R Markdown file, it detects the file, but can't load it. When the focus is in the console, the addin resorts back to manual path specification (the error message is somewhat misleading; this is also happens when the focus isn't on an R Markdown file). In this case, the addin successfully reads the file and I can search the references. However, this only works until I first try it with the focus on the R Markdown file (after that I have to restart my R session to be able to read the file). Could you confirm that the last bit is true in your case as well?
Not 100% sure what you wanted me to do! I've tried with the focus on the Rmd file. I get the popup but not file content (curiously the port number changes I notice... so there is a possibility this is a firewall issue... the port could be closed). That happens with a new R session or not and with the Rmd in focus or not.
I'm only seeing "Falling back to manual" if the Rmd isn't saved. That is a bit 'odd' as if you are mid way through typing a document you wouldn't usually click 'save' before clicking insert citation... Even adding a space does the same.
Oh god, this is a little embarrassing. I was only able to reproduce the problem because I specified bibliography: reference.bib
in the YAML front matter, but saved the file as references.bib
(note the plural s). Now that I have renamed the file, everything works as expected (I haven't looked at your Zotero issue, yet). I'm using the latest citr
version available from this repository. Could you provide the output of devtools::session_info()
?
This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.
I use RStudio Server rather than RStudio Desktop. I'm struggling to get citr to work properly
To Reproduce
Install citr (0.3.0 from Cran or Dev from GitHub) on RStudio Server Create .Rmd file with
Export a bib file and save it to reference.bib Save the .Rmd File
Expected behavior
Popup box appears. Should be able to select from list a reference. But no references appear to select...
Using:
citr:::insert_citation(bib_file = "reference.bib")
has same result
If the add-in is clicked directly with the Rmd file in context the message about Rmarkdown not being saved is not shown. Listening is still shown. No references shown in popup.
If I enter:
So it seems the bib file is accessible - but the pop-up window doesn't seem to be able to access it.
The server does have Zotero Standalone installed - doesn't seem to matter if it is running or not to get the pop-up box to work. With Zotero not running:
With Zotero running: