[R-pkg-devel] troubleshooting hard-to-reproduce errors

Sebastian Meyer @eb@meyer @ending from f@u@de
Tue Jan 8 08:39:23 CET 2019


These issues originate in a change in how R looks for S3 methods, at
least on some of the CRAN machines. To reproduce locally, you currently
need to set the environnment variable

_R_S3_METHOD_LOOKUP_BASEENV_AFTER_GLOBALENV_=TRUE

See the source code at
https://svn.r-project.org/R/trunk/src/main/objects.c

To fix method lookup for R >= 3.6.0, you can use delayed S3 method
registration along the lines of:

if (getRversion() >= "3.6.0") {
  S3method(pkg::gen, cls)
}

See the manual at
https://cran.r-project.org/doc/manuals/r-devel/R-exts.html#Registering-S3-methods

Hope this helps!
Cheers,

	Sebastian


Am 08.01.19 um 04:56 schrieb Ben Bolker:
> 
>  My colleagues and I are preparing a new submission of a package for
> CRAN (https://github.com/glmmTMB/glmmTMB/tree/master/glmmTMB).  We've
> tested it on all the platforms we have access to: Travis/Linux (devel
> and release), MacOS (release), Ubuntu 16.04 (release), win-builder
> (devel and release), without any serious problems.
> 
>  On CRAN's Debian test machine, we get an ERROR and a WARNING.
> 
> 1. Can anyone suggest the best way to test/find a platform where we can
> figure out what's going on? I haven't used R-hub: should I try that?
> 
> 2.  The specific problem is in the "downstream_methods" example:
> <https://github.com/glmmTMB/glmmTMB/blob/master/glmmTMB/man/downstream_methods.Rd#L65-L67>
> 
> warp.lm <- glmmTMB(breaks ~ wool * tension, data = warpbreaks)
> if (require(emmeans)) {
>      emmeans (warp.lm, poly ~ tension | wool)
> }
> 
>  the error is:
> 
>  Loading required package: emmeans
>  Error in ref_grid(object, ...) :
>    Can't handle an object of class  'glmmTMB'
>   Use help("models", package = "emmeans") for information on supported
> models.
>  Calls: emmeans -> ref_grid
>  Execution halted
> 
> 
>  I can imagine that this has something to do with environment/method
> loading.  If I run
> 
> example("downstream_methods", package="glmmTMB")
> 
> in an R console it works fine (even if glmmTMB isn't loaded).
> 
> I can reproduce the error if *without loading the glmmTMB package* I run
> 
> warp.lm <- glmmTMB::glmmTMB(breaks ~ wool * tension, data = warpbreaks)
> if (require(emmeans)) {
>      emmeans (warp.lm, poly ~ tension | wool)
> }
> 
> ... but I don't see why the methods from a package wouldn't be loaded
> when running its own examples ??
> 
> 3. The other problem is in vignette building (see below).  Any
> suggestions for debugging since it doesn't seem to fail locally?
> The lines indicated suggest some similar kind of method-access problem
> <https://github.com/glmmTMB/glmmTMB/blob/master/glmmTMB/vignettes/model_evaluation.rmd#L94-L95>:
> 
> 
> Anova(owls_nb1)  ## default type II
> Anova(owls_nb1,type="III")
> 
>   Any suggestions welcome ...
> 
>  cheers
>    Ben Bolker
> 
> ---
> * checking re-building of vignette outputs ... [80s/81s] WARNING
> Error(s) in re-building vignettes:
>   ...
> --- re-building ‘covstruct.rmd’ using rmarkdown
> 
> Attaching package: 'TMB'
> 
> The following object is masked from 'package:glmmTMB':
> 
>     tmbroot
> 
> --- finished re-building ‘covstruct.rmd’
> 
> --- re-building ‘mcmc.rmd’ using rmarkdown
> --- finished re-building ‘mcmc.rmd’
> 
> --- re-building ‘miscEx.rmd’ using rmarkdown
> --- finished re-building ‘miscEx.rmd’
> 
> --- re-building ‘model_evaluation.rmd’ using rmarkdown
> Loading required package: carData
> lattice theme set by effectsTheme()
> See ?effectsTheme for details.
> Loading required package: mvtnorm
> Loading required package: survival
> Loading required package: TH.data
> Loading required package: MASS
> 
> Attaching package: 'TH.data'
> 
> The following object is masked from 'package:MASS':
> 
>     geyser
> 
> 
> Attaching package: 'multcomp'
> 
> The following object is masked from 'package:emmeans':
> 
>     cld
> 
> Note that, since v0.1.6.2, DHARMa includes support for glmmTMB, but
> there are still a few minor limitations associatd with this package.
> Please see https://github.com/florianhartig/DHARMa/issues/16 for
> details, in particular if you use this for production.
> Loading required package: ggplot2
> Quitting from lines 94-96 (model_evaluation.rmd)
> Error: processing vignette 'model_evaluation.rmd' failed with diagnostics:
> subscript out of bounds
> --- failed re-building ‘model_evaluation.rmd’
> 
> --- re-building ‘sim.rmd’ using rmarkdown
> --- finished re-building ‘sim.rmd’
> 
> --- re-building ‘troubleshooting.rmd’ using rmarkdown
> --- finished re-building ‘troubleshooting.rmd’
> 
> --- re-building ‘glmmTMB.Rnw’ using knitr
> Loading required package: stats4
> Warning in qt((1 - level)/2, df) : NaNs produced
> --- finished re-building ‘glmmTMB.Rnw’
> 
> SUMMARY: processing the following file failed:
>   ‘model_evaluation.rmd’
> 
> Error: Vignette re-building failed.
> Execution halted
> 
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>



More information about the R-package-devel mailing list