Roxygen2: Loading package fails on setOldClass

Created on 27 Jan 2017  Â·  11Comments  Â·  Source: r-lib/roxygen2

For the record only, because I realized that things works fine with devtools::document.

If the package to document contains a call to setOldClass, then roxygenise fails with the following error:

Loading required package: roxygen_devtest
Error in .requirePackage(package) : 
  unable to find required package ‘roxygen_devtest’
In addition: Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  there is no package called ‘roxygen_devtest’

traceback shows:

13: stop(gettextf("unable to find required package %s", sQuote(package)), 
        domain = NA)
12: .requirePackage(package)
11: makeExtends(name, what, slots = slots, classDef2 = whatClassDef, 
        package = package)
10: makeClassRepresentation(Class, properties, superClasses, prototype, 
        package, validity, access, version, sealed, where = where)
9: setClass(cl, contains = c(prevClass, "VIRTUAL"), where = where)
8: setOldClass("A")
7: eval(expr, envir, enclos)
6: eval(expr, envir = envir)
5: FUN(X[[i]], ...)
4: lapply(paths, sys_source, envir = env, fileEncoding = desc$Encoding %||% 
       "UTF-8")
3: load_code(base_path)
2: parse_package(base_path, load_code, registry, options)
1: roxygen2::roxygenise("~/projects/tmp/A")
feature

Most helpful comment

Can we get some kind of estimate of when this might be fixed? Is it a big problem requiring lots of substantial development or, potentially, a 1 line fix?

All 11 comments

Hm, so until this is fixed, the workaround is to use devtools::document? But I definitely don't want to wait for all the C++ source code to compile. Is there some other way to persuade roxygen2::roxygenise to work?

FWIW: I'm also seeing this problem when I try build my NAMESPACE. The method I use is

echo "library(roxygen2); roxygenize('.')" | R --slave

Which worked just fine with 5.x.x, but now breaks with the error that was reported above (cannot find roxygen_devtest)

Can we get some kind of estimate of when this might be fixed? Is it a big problem requiring lots of substantial development or, potentially, a 1 line fix?

have similar issue here.

It works when I re-install old version (5.0.1).

Hm, I was using the old class packageVersion. I guess it is simple enough to apply as.character and pacakge_version as needed to avoid storing this class in an object.

I noticed this problem too when my package had other (non-related) errors that prevented it from being built. After correcting the other errors and rebuilding the package roxygenize worked fine.

Still having this with latest (as of today) version from GitHub installed,

The devtools::document() workaround works for me.

Error in .requirePackage(package) : 
  unable to find required package ‘roxygen_devtest’
In addition: Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  there is no package called ‘roxygen_devtest’
> roxygenise("Rpkg")
Loading required package: roxygen_devtest
Error in .requirePackage(package) : 
  unable to find required package ‘roxygen_devtest’
In addition: Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  there is no package called ‘roxygen_devtest’
> traceback()
12: stop(gettextf("unable to find required package %s", sQuote(package)), 
        domain = NA)
11: .requirePackage(package)
10: makeExtends(name, what, slots = slots, classDef2 = whatClassDef, 
        package = package)
9: makeClassRepresentation(Class, properties, contains, prototype, 
       package, validity, access, version, sealed, where = where)
8: setClass("TransformedModel", contains = "Model", slots = c(transforms = "list", 
       inverses = "list"))
7: eval(expr, envir = envir)
6: eval(expr, envir = envir)
5: FUN(X[[i]], ...)
4: lapply(paths, sys_source, envir = env, fileEncoding = desc$Encoding %||% 
       "UTF-8")
3: load_code(base_path)
2: parse_package(base_path, load_code, registry, options)
1: roxygenise("Rpkg")

We should be able to fix this now that the package loading simulation has been extracted out of devtools and into pkgload. However, in general, there is no way to avoid recompiling code because you may be documenting C++ functions.

However, in general, there is no way to avoid recompiling code because you may be documenting C++ functions.

That's disappointing. Is there some way to invoke roxygen2 to tell it that we don't care about C++ functions and compilation can be skipped?

I don't understand why it's a problem because you only need to recompile when the C++ code changes.

Oh! That is an improvement. I'll let you know how things go.

Was this page helpful?
0 / 5 - 0 ratings