Issue by epurdom
Wednesday Jun 07, 2017 at 19:15 GMT
Originally opened as r-lib/devtools#1523
Hello,
This error has been reported in #657, #168, #240. All of those issues to devtools are closed issues, so I am opening a new issue with what I hope is a reproducible example. I am using R 3.4.0, devtools_1.13.2. It's also been mentioned in the issues of other packages (ropensci/datapack#23, epurdom/clusterExperiment#175)
The issue is that load_all fails with setClassUnion calls. In my case one of the members is NULL
, which ropensci/datapack#23 believes to be the problem. And indeed, I do not get the problem on my minimal example if I keep only the setClassUnion
call that doesn't involve NULL
.
I create a package with a minimal R code with the following setClassUnion calls (see also package attached demoPackageLoadError.zip
)
setOldClass("dendrogram")
setClassUnion("dendrogramOrNULL",members=c("dendrogram", "NULL"))
setClassUnion("matrixOrNULL",members=c("matrix", "NULL"))
setClassUnion("matrixOrMissing",members=c("matrix", "missing"))
setClass(
Class = "A",
slots = list(
myOtherSlot="matrix",
myDendro = "dendrogramOrNULL",
myMatrix = "matrixOrNULL"
)
)
I install this package on my computer with R CMD INSTALL.
The following load_all
command DOES work:
> setwd("~/Documents/RfunctionsGenerally/demoPackageLoadError/")
> library(devtools)
> load_all()
Loading demoPackageLoadError
> library(demoPackageLoadError)
> load_all()
Loading demoPackageLoadError
Warning message:
class "dendrogram" is defined (with package slot ‘demoPackageLoadError’) but no metadata object found to revise superClass information---not exported? Making a copy in package ‘demoPackageLoadError’
However, the following commands (on a new R session) does NOT work. This is run within RStudio, but I have the same problem in R.app at the terminal. I would note that the error message I get has changed slightly since I updated to R 3.4. I was not previously getting the error about get0
but only the second error. (This is based solely on my memory from frequently seeing the error on my full package, but I haven't tried different R versions with this minimal example).
> library(demoPackageLoadError)
> library(devtools)
> load_all()
Loading demoPackageLoadError
Error in get0(cname, where, inherits = inherits) :
invalid 'envir' argument
Show Traceback
Rerun with Debug
Error in setClassUnion("dendrogramOrNULL", members = c("dendrogram", "NULL")) :
unable to create union class: could not set members "NULL"
The above code does work if I keep only the "matrixOrMissing"
class. It does not work once I add back in just the matrixOrNULL
class (so its not because of the dendrogram
class).
I would also note the first code above that I said works with my minimal example, actually fails on my full package (in github: epurdom/clusterExperiment ). I can't yet recreate the failure I see on my full package on the first set of code with this minimal example. But I am hoping that fixing one would fix the other.
However, if it is helpful, I think I used to be able to use that code for my full package like the above minimal example before I moved to R 3.4 -- at least I use to be able to get it to sometimes work for me in R 3.3 for my full package and now it never works. I didn't know at the time why sometimes it worked and sometimes it didn't, but now having systematically run this minimal example I'm guessing it worked sometimes depending on the order of calling of my packages. Now I can no longer use load_all
in any way for my full package which finally prompted me to make a minimal example, systematically test it, and report!