Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"'knitr' not found" error during package / vignette build

Tags:

r

knitr

I'm using knitr to build an R package vignette. This process worked before R 3.0, but I haven't been able to rebuild the package under R 3.1.1.

When I try R CMD build I get an error message:

R CMD build Causata
* checking for file ‘Causata/DESCRIPTION’ ... OK
* preparing ‘Causata’:
* checking DESCRIPTION meta-information ... OK
* installing the package to build vignettes
* creating vignettes ...

ERROR Error in loadVignetteBuilder(vigns$pkgdir) :
  vignette builder 'knitr' not found Calls: <Anonymous> -> loadVignetteBuilder
In addition:
  Warning message: In tools::buildVignettes(dir = ".", tangle = TRUE) :
  Files named as vignettes but with no recognized vignette engine:
   ‘vignettes/Causata-vignette.rnw’ (Is a VignetteBuilder field missing?)
Execution halted

My vignette file has a VignetteEngine call -- here are the first three lines:

% !Rnw weave = knitr 
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{Model training and export}

My package description file includes a VignetteBuilder field:

VignetteBuilder: knitr

I think I'm following the instructions for Rnw vignettes, so I'm baffled by the error message I'm seeing.

Incidentally, if I try to build the vignette directly then everything seems to work perfectly. This command generates the vignette PDF:

tools::buildVignettes(dir=".", tangle=TRUE)

My trouble seems to be only with R CMD build. Why won't the build work?

Here's my complete package DESCRIPTION file for reference:

Package: Causata
Type: Package
Title: Analysis utilities for binary classification and Causata users.  
Version: 5.0-1
Date: 2014-10-09
Author: Justin Hemann, David Barker, Suzanne Weller, Jason McFall
Maintainer: Justin Hemann <[email protected]>
Description: The Causata package provides utilities for 
    extracting data from the Causata application, training regression / classification 
    models, and exporting models as PMML for scoring.
Depends: R (>= 2.15.1)
Imports: XML, R.utils, rjson, RCurl, stringr, yaml, boot, foreach, data.table, glmnet, ggplot2, methods
Suggests: knitr, doMC, testthat, pROC, RODBC, RMySQL
VignetteBuilder: knitr
License: GPL
LazyLoad: yes
URL: www.nice.com
like image 640
Justin Avatar asked Oct 14 '14 18:10

Justin


1 Answers

According to the feedback of Josh O'Brien, I guess you might have the same issue as him. If you want to add some custom library paths, I'd recommend you to do it in ~/.Renviron using the environment variable R_LIBS_USER, instead of defining the library paths in ~/.Rprofile or Rprofile.site. The latter seems to be ignored by R CMD build and R CMD check.

like image 66
Yihui Xie Avatar answered Nov 04 '22 19:11

Yihui Xie