Question

I am writing a script that uses roxygen2 to automatically roxygenize my package. I'd like it to be executable so that it can be part of a larger script to prepare and install the package, but I cannot make it work with Rscript for some reason.

Here is the code:

#!/usr/bin/env Rscript
library(roxygen2)
roxygenize('.', copy=FALSE)

This works correctly if I start an interactive R session or if I submit the code using R CMD BATCH. However, I get this output and error if I run the script directly as an executable via Rscript (and I get the error regardless of whether the script is in the current directory or bin).

bin/roxygenize.R 
Loading required package: digest
Warning message:
package 'roxygen2' was built under R version 2.13.2 
Error in parse.files(r_files) : could not find function "setPackageName"
Calls: roxygenize -> parse.files
Execution halted

It looks like setPackageName is in base R, so I can't figure out why it's not there. Additionally, I use Rscript in lots of other situations and this seems to be the only place that it fails.

Any help is much appreciated.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top