简体   繁体   中英

Strange bug in R package check: cleanEx() or dev.off()

I'm not sure what's going on here...I'm trying to develop an R package for Bioconductor, and there's a strange bug showing up when examples are run in the package check.

Running examples in ‘MMAPPR2-Ex.R’ failed
The error most likely occurred in:
> ### Name: prePeak
> ### Title: Identify chromosomes containing peaks
> ### Aliases: prePeak
> 
> ### ** Examples
> 
> postPrePeakMD <- prePeak(postLoessMD)
> 
> 
> 
> ### * <FOOTER>
> ###
> cleanEx()
> options(digits = 7L)
> base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
Time elapsed:  423.952 27.296 464.105 0.004 0.14 
> grDevices::dev.off()
Error in grDevices::dev.off() : 
  cannot shut down device 1 (the null device)

As you can see, the bug is not in my code, but rather in this "FOOTER" section automatically generated afterwards. I don't know how my package could have messed up graphics devices, since it only deals them with one spot, and I commented out where that part gets run in the examples. I'm not sure what to do.

Here's the Travis build with the problem in question: https://travis-ci.org/kjohnsen/MMAPPR2/builds/436922565

I experienced the same issue. In my case devtools::check() was identifying the error as being in a different function than where it actually was, presumably because the automated dev.off() call was happening only when the second function's examples were checked. I could not solve it by simply commenting things out because the offending graphics code was not in examples but in the function itself. If I commented out the graphics.off() and/or dev.off() in my function there was a potential error if more than 62 devices were opened. So what I did was to add the following line of code: if(length(dev.list()) > 60) graphics.off() . That did the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM