[Rd] package vignettes build in the same R process?

Wolfgang Huber whuber at embl.de
Sat Nov 8 09:29:49 CET 2014


Il giorno Nov 2, 2014, alle ore 16:10 GMT+1, Duncan Murdoch <murdoch.duncan at gmail.com> ha scritto:

> On 01/11/2014, 8:44 PM, Martin Morgan wrote:
>> If I understand correctly, all vignettes in a package are built in the same R 
>> process. Global options, loaded packages, etc., in an earlier vignette persist 
>> in later vignettes. This can introduce user confusion (e.g., when a later 
>> vignette builds successfully because a package is require()'ed in an earlier 
>> vignette, but not the current one), difficult-to-identify bugs (e.g., when
>> a setting in an earlier vignette influences calculation in a latter vignette), 
>> and misleading information about reproducibility (e.g., when the sessionInfo() 
>> of a later vignette reflects packages used in earlier vignettes).
>> 
>> I believe the relevant code is at
>> 
>> src/library/tools/R/Vignettes.R:505
>> 
>>         output <- tryCatch({
>>             ## FIXME: run this in a separate process
>>             engine$weave(file, quiet = quiet)
>>             setwd(startdir)
>>             find_vignette_product(name, by = "weave", engine = engine)
>>         }, error = function(e) {
>>             stop(gettextf("processing vignette '%s' failed with diagnostics:\n%s",
>>                  file, conditionMessage(e)), domain = NA, call. = FALSE)
>>         })
>> 
>> Is building of each vignette in separate processes a reasonable feature request?
> 
> I'm not sure.  It's not perfect:  users may still see different output
> than the package contains, because when they run the vignette it will
> see their system state, but at least it gives them a way to get the
> identical output.  On the other hand, they already have a way to do
> that:  just build the whole package.  Overall I'd say it's probably a
> good idea.

Let the perfect be the enemy of the good?
Martin’s proposed improvement would eliminate unnecessary complexity and a lot of potential (and actual) confusion.

Wolfgang Huber

> 
> I would prefer a way to detect and warn when vignette output depends on
> the state outside the vignette, but that looks hard to do.
> 
> Duncan Murdoch
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list