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.
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