Can't disable vignette build when using devtools - r

When running
==> devtools::check(args = c('--no-build-vignettes','--no-vignettes'))
from RStudio the vignettes are still being build:
...
v checking DESCRIPTION meta-information ...
- installing the package to build vignettes (1.4s)
creating vignettes ...
I configured the Build tools according to:
https://support.rstudio.com/hc/en-us/articles/200486518-Customizing-Package-Build-Options
Should including
--no-vignettes do not run R code in vignettes
--no-build-vignettes do not build vignette outputs
not disable the vignette build?

I think you want build_args, which is for arguments passed while building the package, not args which is for arguments passed while checking.

Related

Cannot install vignette from an R package on GitHub

I coded an R package that is hosted on my GitHub. I included a vignette, and I can install the package and load the vignette without any issue from R and RStudio by doing:
devtools::install_github("rosalieb/serac", build_vignettes = TRUE)
library(serac)
vignette("serac")
However, I have a few colleagues who cannot install the vignette (the only way they can download the package is by doing devtools::install_github("rosalieb/serac") (default of build_vignettes is FALSE).
It works if they use RStudio, but not in 'regular' R.
I encourage people to use RStudio, but I cannot force them, and eventually, I do not understand why it would work in 'regular' R for me but not for them.
They tried to install pandoc, knitr, Rtools - none of these worked.
Here is the error message when my colleague tries to install the package with the vignette:
v checking for file 'C:\Temp\RtmpO8YwVb\remotesf9842f1431\rosalieb-serac-46a3587/DESCRIPTION'
- preparing 'serac':
checking DESCRIPTION meta-information ...
checking DESCRIPTION meta-information ...
v checking DESCRIPTION meta-information
- installing the package to build vignettes
creating vignettes ...
creating vignettes ...
E creating vignettes (4.9s)
--- re-building 'serac.Rmd' using rmarkdown
Error: processing vignette 'serac.Rmd' failed with diagnostics:
Pandoc is required to build R Markdown vignettes but not available. Please make sure it is installed.
--- failed re-building 'serac.Rmd'
RESUME : le traitement du fichier suivant a échoué :
'serac.Rmd'
Erreur : Vignette re-building failed.
Exécution arrêtée
Erreur : Failed to install 'serac' from GitHub:
System command 'Rcmd.exe' failed, exit status: 1, stdout & stderr were printed
Thanks in advance for your help!
The message indicates that rmarkdown::render can't find Pandoc.
It looks for it in three places: in the directory specified by the RSTUDIO_PANDOC environment variable, in directories on the PATH, in the directory opt/pandoc in the user's home directory. So your colleagues who have installed it should make sure it is available in one of those locations. They can see the current values of the environment variables by running
Sys.getenv("PATH")
and
Sys.getenv("RSTUDIO_PANDOC")
Temporary changes can be made using
Sys.setenv(RSTUDIO_PANDOC="/path/to/pandoc/directory")
This needs to happen in the session that is trying to install the package and build the vignette, not in the vignette itself.
How to make permanent changes to those values depends on the details of what system they are running.

Loading R package in vignette for the package itself

I am currently building an R package, call it mypackage. I generated a package vignette using devtools::use_vignette("my-vignette"), and filled in my-vignette with content. Of course, because it is a package vignette, I need to demonstrate the use of the functions and data contained in this package itself. However, I'm having issues loading the package and its contents when knitting the vignette.
All of the code chunks in the vignette run without error on my local computer, even after restarting R and clearing the workspace. However, when I attempt to build the package using devtools::build(), the build fails with:
Error in library(mypackage): there is no package called `mypackage` Calls: <Anonymous> ... withCallingHandlers -> withVisible -> eval -> eval -> library Execution halted
The full output in the Console from devtools::build() is:
* checking for file ‘/path/to/mypackage/DESCRIPTION’ ... OK
* preparing ‘mypackage’:
* checking DESCRIPTION meta-information ... OK
* installing the package to build vignettes
* creating vignettes ... ERROR
Quitting from lines 39-44 (my-vignette.Rmd)
Error: processing vignette 'my-vignette.Rmd' failed with diagnostics:
'my_function' is not an exported object from 'namespace:mypackage'
Execution halted
devtools::document() runs without error, but devtools::build_vignettes() aparently reaches a different error where it cannot use a specific function (but seems to be able to load the package itself):
> devtools::build_vignettes()
Building mypackage vignettes
Moving basic-mypackage-vignette.html, basic-mypackage-vignette.R to inst/doc/
Copying basic-mypackage-vignette.Rmd to inst/doc/
> devtools::build()
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet CMD build \
'/path/to/mypackage' --no-resave-data --no-manual
* checking for file ‘/path/to/mypackage/DESCRIPTION’ ... OK
* preparing ‘auctestr’:
* checking DESCRIPTION meta-information ... OK
* installing the package to build vignettes
* creating vignettes ... ERROR
Quitting from lines 39-44 (my-vignette.Rmd)
Error: processing vignette 'my-vignette.Rmd' failed with
diagnostics:
could not find function "my_function"
Execution halted
Error: Command failed (1)
> devtools::document()
Updating mypackage documentation
Loading mypackage
I assume this is because the package itself does not exist in my R library; I am just loading that package using devtools::load_all() when doing development. How can I get around this and load my package in order to use its functions and data in the package vignette? Specifically, how can I make the package in its functions available to whatever environment knitr is using to knit the vignette?
I have seen other package vignettes load the package directly using library() without issue; for example, in the stringr vignette.
I hope readers can evaluate this without a fully reproducible example; reproducing the entire example is difficult because it requires a full R package directory structure that is difficult to replicate or share here.
I do load directly my package in my vignettes (library(my_package)).
But considering your error, it might not be the problem...
Can you make sure that my_function is indeed exported. You should add the following code ate the end of the documentation of your function.
#' #export
I added a chunk
```{r, include=FALSE}
devtools::load_all(".")
```
at the beginning of the vignette to work around the problem.
However, this doesn't fix the actual problem, as this should not be necessary.
Alternatively you could use the ::: notation, especially if you are not exporting that function, e.g.
mypackage:::my_function()

Travis-CI: Knitr Not Found in loadVignetteBuilder

I've been using travis-ci successfully so far but I'm having trouble when using travis-ci with R 3.4.0 at the vignette building step with the following error in the "building package" section:
* installing the package to build vignettes
* creating vignettes ... ERROR
Error in loadVignetteBuilder(vigns$pkgdir) :
vignette builder 'knitr' not found
Calls: <Anonymous> -> loadVignetteBuilder
Execution halted
When I run R-CMD-check locally it passes and I don't get any errors
Here's the current .travis.yml
language: R
sudo: false
install:
- R -e "0" --args --bootstrap-packrat
cache:
directories:
- $TRAVIS_BUILD_DIR/packrat/src
- $TRAVIS_BUILD_DIR/packrat/lib
packages: true
r_packages:
- covr
after_success:
- Rscript -e 'library(covr); codecov()'
DESCRIPTION has the vignette line in it:
VignetteBuilder: knitr
knitr is also in my packrat.lock file and packrat is used for the build in .travis.yml.
I've tried the following to no avail:
added knitr to the r_packages in .travis.yml
added knitr to the Imports in DESCRIPTION
added r_check_args: "--no-vignettes" to travis.yml in the hopes of skipping the vignette building step.
added packrat call in travis.yml from install to before_install
I'm pretty knew to building R packages, never mind travis-ci so I'm not sure if I understand why the vignette builder would not have access to the knitr package.
Repo: https://github.com/cormac85/datakindr
Travis: https://travis-ci.org/cormac85/datakindr
One potential problem involves the 'Imports' and/or 'Suggests' sections in your description file.
dplyr needs to be in your suggests, if not imports.
See Hadley's 2015 O'Reilly book, R Packages:
Common problems:
The vignette builds interactively, but when checking, it fails with an error about a missing package that you know is installed. This means that you’ve forgotten to declare that dependency in the DESCRIPTION (usually it should go in Suggests).
So in the end I got the build to pass by just removing packrat config from .travis.yml and replacing it with the normal package building config: cache: packages.
The packrat config I used was suggested in the Travis R Documentation and worked well for the rest of the items in the package but it did not work for the loadVignetteBuilder() step during the build.

How to resolve NOTE in `R CMD check` when include static PDF file in vignette?

I wish to include a static PDF file in vignette of my R package biglasso. I followed the instruction here and here. However when I run R CMD check, there is always a NOTE saying:
Vignette sources in 'inst/doc' with no 'vignettes' directory:
'biglasso.pdf.asis'
A 'vignettes' directory is required as from R 3.1.0
and
* checking for old-style vignette sources ... NOTE
Vignette sources only in 'inst/doc':
'biglasso.pdf.asis'
A 'vignettes' directory is required as from R 3.1.0
and these will not be indexed nor checked
Here is the complete package check information.
Could anyone explain to me what this note means and how to fix it?

Building R package: "No man pages found in package"

My previously-functioning R package lllcrc recently broke, so I tweaked it, and now I'm having trouble building it again because it acts like it can't see my documentation files:
R CMD INSTALL lllcrc
* installing to library ‘/home/[...]/3.1’
* installing *source* package ‘lllcrc’ ...
** R
** preparing package for lazy loading
** help
No man pages found in package ‘lllcrc’
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (lllcrc)
This is totally weird because I definitely have a complete set of .Rd files in the man folder; in fact, I generated all of these using roxygen2, and all of this worked previously. The R CMD INSTALL even works enough so that the package actually installs and all of its examples run. But documentation is missing. Running ?foo just gives a "no documentation" message.
Another thing: R CMD Rd2pdf lllcrc generates the .pdf documentation as I would expect.
Any ideas?
I just had the same error message ... if you are using roxygen and RStudio then your problem might be the same. The reason became apparent when looking at "Configure build tools" in the "Build" drop-down menu: you need to tick the checkbox "Generate documentation with Roxygen". After that, everything worked.

Resources