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

Does knitcitations work outside of the RStudio Enviroment? e.g. build and check? #96

Open
bryanhanson opened this issue Aug 1, 2016 · 6 comments

Comments

@bryanhanson
Copy link

I'd like to use knitcitation outside RStudio, specifically in the CRAN build and check process, using an .Rmd file. I have the vignetteEngine set to knitr. In the vignette I'm doing:

suppressPackageStartupMessages(library("knitcitations"))
cleanbib()
jnk <- read.bibtex("unmixing.bib")

and then where I want an inline citation I'm doing

r citep("SomeAuthor2011")

But the system doesn't see my .bib file doing this (I don't think read.bibtex was really intended for use this way). Since it is the CRAN system I don't think I can do any yaml.
Is this possible? Or is another package the better way to go? Thanks.

@cboettig
Copy link
Owner

cboettig commented Aug 1, 2016

Thanks for the report -- the system should be doing the same thing regardless of whether or not you are using RStudio. My guess is that you might have a path problem in your non-rstudio instance. Does the above work for you fine in RStudio?

@bryanhanson
Copy link
Author

Thanks Carl.

I'm not exactly sure how to run this in RStudio (though I have colleague I can consult). In the meantime, here is the top of the vignette and the citep call:

<!--
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{Intro to unmixR}
 -->

Hyperspectral Unmixing
========================================================

Bryan A. Hanson, July 29, 2016

{r setup, echo = FALSE}
suppressPackageStartupMessages(library("knitcitations"))
cleanbib()
jnk <- read.bibtex("unmixing.bib")

Some words...

* Biomedical imaging: `r citep("Hedegaard2011")`

And build says:

R CMD build unmixR
* checking for file ‘unmixR/DESCRIPTION’ ... OK
* preparing ‘unmixR’:
* checking DESCRIPTION meta-information ... OK
* installing the package to build vignettes
* creating vignettes ... ERROR
query "Hedegaard2011" returned no matches
Quitting from lines 25-133 (IntroUnmixR_2.Rmd) 
Error: processing vignette 'IntroUnmixR_2.Rmd' failed with diagnostics:
argument "bibtype" is missing, with no default
Execution halted
make: *** [build] Error 1

The .bib file is present in the directory and the bib entry is valid. bibtype seems clear:

@article{ Hedegaard2011,
Author = {Hedegaard, Martin and Matthaeus, Christian and Hassing, Soren and
   Krafft, Christoph and Diem, Max and Popp, Juergen},
Title = {{Spectral unmixing and clustering algorithms for assessment of single
   cells by Raman microscopic imaging}},
Journal = {{THEORETICAL CHEMISTRY ACCOUNTS}},
Year = {{2011}},
Volume = {{130}},
Number = {{4-6}},
Pages = {{1249-1260}},
Month = {{DEC}},
DOI = {{10.1007/s00214-011-0957-1}},
ISSN = {{1432-881X}}
}

I found a rather different approach here which suggests that you can have yaml in there and still make it through CRAN but my first stab at that approach gave a different error, which I haven't had time to work on yet.

@cboettig
Copy link
Owner

cboettig commented Aug 1, 2016

Just trying to make sure we can isolate the issue: does everything work fine when you run interactively in R, and fail only on building as a vignette when building the package? Or has the above never worked in any way for you? (i.e. I can't really trouble-shoot without a minimal reproducible example of the error).

As a side note, while it should work fine in principle in vignette building, I don't actually recommend having vignettes that require calls to external APIs of any kind, including citation databases used by knitcitations, in packages going to CRAN. CRAN's test servers can have slow responses sometimes that will cause external network queries to time out sometimes, leading to random package build & test failures.

@bryanhanson
Copy link
Author

I’m attaching a minimal failing example. From the command line R CMD BUILD minPkg throws the error mentioned.

On your side note: This should be stand alone and not ask knitcitations to search for anything.

This is no doubt going to be something foolish on my part; thanks for bearing with me. Bryan

On Aug 1, 2016, at 3:33 PM, Carl Boettiger [email protected] wrote:

Just trying to make sure we can isolate the issue: does everything work fine when you run interactively in R, and fail only on building as a vignette when building the package? Or has the above never worked in any way for you? (i.e. I can't really trouble-shoot without a minimal reproducible example of the error).

As a side note, while it should work fine in principle in vignette building, I don't actually recommend having vignettes that require calls to external APIs of any kind, including citation databases used by knitcitations, in packages going to CRAN. CRAN's test servers can have slow responses sometimes that will cause external network queries to time out sometimes, leading to random package build & test failures.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub #96 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/AAIkPqNwsNZ5jiQBsLgEmt0F2gwYrmPvks5qbkn6gaJpZM4JZ1Ue.

@cboettig
Copy link
Owner

cboettig commented Aug 2, 2016

I don't think you can attach examples to issues in that way. A minimal example that did not involve building a package would be ideal (unless that's the only case in which you see the error).

Note that the knitcitations package includes a vignette (though it may not demo the particular pattern you want), but perhaps you can try cloning and building knitcitations (maybe tweaking the vignette to match your case if/once it works as is) would help you debug?

@bryanhanson
Copy link
Author

Sorry, I forgot to check that the files made it through. But, even simpler is better, and as it turns out, more informative. I'm attaching 2 files, an .Rmd and a .bib (had to add .txt as Github won't accept .bib and .Rmd). If I knit the .Rmd, I get the following error (this is in the Mac R GUI app):

query "Hedegaard2011" returned no matches
Quitting from lines 17-17 (minPkg.Rmd) 
Error in (function (bibtype, textVersion = NULL, header = NULL, footer = NULL,  : 
  argument "bibtype" is missing, with no default

Looks like it may be coming from an lapply call to knit_cite.

Thanks, Bryan

minPkgbib.txt
minPkgRmd.txt

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

2 participants