Travis-CI: Knitr Not Found in loadVignetteBuilder - r

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.

Related

Travis CI cannot find packages in the pkg-config search path

I've recently started encountering the same errors on my various R packages updated after mid-December on Travis-CI (https://travis-ci.org/TGuillerme/). This is specially weird since for the three concerned packages, the changes were not any code change (only comments changes) but Travis-CI seems now not able to install some packages (namely magick and libgit2) using a pretty simple .yml file runing the package and codecov for coverage:
language: r
warnings_are_errors: false
branches:
only:
- master
- release
except:
- CRAN
# Code coverage
r_packages:
- covr
after_success:
- Rscript -e 'library(covr); codecov(token = "5f041826-63f1-47fa-b4a8-9a32633f47fa")'
The error I get in this case (although it varies with the different packages) is with the magick package:
** package ‘magick’ successfully unpacked and MD5 sums checked
Package Magick++ was not found in the pkg-config search path.
Perhaps you should add the directory containing `Magick++.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Magick++' found
Using PKG_CFLAGS=
Using PKG_LIBS=-lMagick++-6.Q16
line 2625-2631
Along with one suspicious message prior to this:
Unable to find the libgit2 library on this system. Building 'git2r'
using the bundled source of the libgit2 library.
line 1563-1564
Is there something obvious that I am missing? Is there a way to force Travis-CI to automatically install the the errored packages?
Again, this is specially weird to me since the running code changes committed do not differ since last build running without errors.
I have been able to fix similar issues by installing packages from their binaries.
The following might help in the .travis.yml:
r_binary_packages:
- libgit2
- magick

R Travis CI error: Package suggested but not available: ‘ridge’

I am trying to run Travis CI for one of my R packages. The problem is the build fails with an error stating that one dependency of the package is not available (the package named 'ridge')
Here the error log:
* checking extension type ... Package
* this is package ‘imputeR’ version ‘2.1’
* checking package namespace information ... OK
* checking package dependencies ... ERROR
Package suggested but not available: ‘ridge’
The suggested packages are required for a complete check.
Checking can be attempted without them by setting the environment
variable _R_CHECK_FORCE_SUGGESTS_ to a false value.
See section ‘The DESCRIPTION file’ in the ‘Writing R Extensions’
manual.
* DONE
Status: 1 ERROR
See
‘/home/travis/build/SteffenMoritz/imputeR/imputeR.Rcheck/00check.log’
for details.
0.38schecking package dependencies ... ERROR
Package suggested but not available: ‘ridge’
Here is also the link to the Travis built:
https://travis-ci.org/SteffenMoritz/imputeR/builds/436334069
The package that is not available to Travis is a normal package that is currently on CRAN. Could this be related to Gnu Scientific Library version >= 1.14 being required for ridge..? Can I somehow solve this problem?
You are right by saying that it is because ridge requires an external library (Gnu Scientific Library) that is not installed by default on travis.
Travis CI docs explain in detail how you can install external packages.
In your case, you need to add
addons:
apt:
packages: libgsl0-dev
to your .travis.yml
Found a solution that let's at least TRAVIS complete the check
You can add this to the Travis configuration yaml file:
env:
global:
- _R_CHECK_FORCE_SUGGESTS_: false
Downside as far as I understand is: everything which includes suggested packages is not checked at all. So the solution is not completely satisfying.

R package dependency error on travis-ci but not local machine

I am trying to build my first R package (GitHub link). It is currently passing all local checks with devtools::check(), but failing on Travis:
ERROR: dependency ‘Rmpfr’ is not available for package ‘streamDepletr’
Looking at the Installed package versions section of the travis-ci output, Rmpfr is not listed. However, my DESCRIPTION file includes it as an import:
Imports:
Rmpfr,
dplyr,
magrittr
and Rmpfr is available on CRAN; my question is, how do I get travis-ci to install it?
The solution may be related to this previous question where the author had to include Java in their .travis.yml file. For Rmpfr, it looks like the MPFR C library is necessary. Is there a way to instruct travis to install this library in my .travis.yml file? Or am I barking up the wrong tree?
As you found out, you need the libmpfr-dev package to be installed. You can do this by adding
addons:
apt:
packages:
- libmpfr-dev
to your .travis.yml. See the documentation for reference.

Using R package source files in packrat (rather than CRAN) with Travis-CI

I'm working with an R package that is an RStudio project, and I'm using packrat to keep a local copy of the source of the packages I depend on for my project.
I've got Travis-CI checking my R package each time I make a commit, but each time Travis builds my package it gets the latest version of the dependent packages, rather than the versions I've got in my packrat/ directory.
I can see in richfitz/wood that he appears to have achieved this goal with this in his .travis.yml file:
env:
USE_PACKRAT=1
and a fairly complex make/packrat.mk file which makes it all work.
My question is what is the simplest way to configure my project (e.g. my .travis.yml file) to tell the Travis machine to get the packages from my packrat/ directory on github, and not from CRAN?
After much trial and error and further reading, it seems that this will do it, with a .travis.yml file like this:
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r
language: R
sudo: false
cache: packages
install:
- R -e "0" --args --bootstrap-packrat
warnings_are_errors: false
The key lines in the above file are:
install:
- R -e "0" --args --bootstrap-packrat
This will start R, and builds the R packages in the local packrat directory so that they are available in the Travis machine.
After that, travis will continue and attempt to build the package, and will not need contact CRAN to get the dependencies because they are already available (assuming packrat is working as expected).
I discovered this trick here: https://travis-ci.org/ChowHub/paper-pattern-similarity/builds/127262823 and at https://github.com/rstudio/packrat/issues/158. I've got it working here: https://travis-ci.org/benmarwick/mjbtramp/builds/157747326
The advantage of this is we can build on travis with the exact same packages that we're using locally. We don't have to get the latest packages from CRAN when we build on travis, now we can have more control of the package versions that travis builds with in our project.
The disadvantage is that the build time on travis is substantially increased. One of my projects went from 2-3 mins to 13-15 mins after switching to packrat.
UPDATE After Noam's question below and Jim's comment, it seems we can cache the packrat packages using cache: like this:
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r
language: R
sudo: false
cache:
directories: $TRAVIS_BUILD_DIR/packrat/
packages: true
install:
- R -e "0" --args --bootstrap-packrat
warnings_are_errors: false
In my use-case, this has reduced the times substantially, back to 1-2 mins.

Error while building R package on Travis CI" "tlmgr update --self" failed

I was building an R package on https://travis-ci.org/ and got an error:
The command "tlmgr update --self" failed and exited with 25 during .
The last lines of Travis CI output:
When I call devtools::check() locally on Windows 10 in RStudio no errors nor warnings arise.
I found that tlmgr concerns with LaTeX/TexLive packages, and In Travis CI documentation "Building an R Project" it's written that some LaTeX/TexLive may be need to be installed if vignettes require. (Note: there are no vignettes in my package yet.)
Configuration in .travis.yml file:
language: R
sudo: false
cache: packages
r_github_packages:
- jimhester/covr
after_success:
- Rscript -e 'covr::codecov()'
My question: what is the cause of the problem and how to solve it?
It seems that tlmgr can't accessing the current repository, you can rollback the repository to the archived version with:
tlmgr option repository ftp://tug.org/historic/systems/texlive/2015/tlnet-final
which gaves
tlmgr: setting default package repository to ftp://tug.org/historic/systems/texlive/2015/tlnet-final
Source: A little trick with tlmgr: Unknown directive …containerchecksum error

Resources