NAMESPACE option created by RcppArmadillo.package.skeleton causes error
Asked Answered
J

1

9

I'm creating a R package that contains Rcpp functions depending on RcppArmadillo, so I first generate the package skeleton by RcppArmadillo.package.skeleton. However, when I roxygenize my package, it gives me an error shown below.

R code

library(roxygen2)
library(RcppArmadillo)
library(Rcpp)
RcppArmadillo.package.skeleton(name = "prac_181206", example_code = FALSE)
roxygenize(package.dir =  "prac_181206", roclets = "rd")

Error

Error in getDLLRegisteredRoutines.DLLInfo(dll, addNames = FALSE) : 
  must specify DLL via a “DLLInfo” object. See getLoadedDLLs()

After spending some time, I figured out this can be solved by removing .registration option in NAMESPACE file given as follows.

Original NAMESPACE file

useDynLib(prac_181206, .registration=TRUE)
importFrom(Rcpp, evalCpp)
exportPattern("^[[:alpha:]]+")

In short, after changing the first line above to useDynLib(prac_181206), it works fine, but I don't understand what the error means and why my solution works.

Could you anyone help me with this matter? I appreciate it!

Because this is a toy example, hopefully reproducible, I didn't include any other functions in man or src folders created by RcppArmadillo.package.skeletonabove.

FYI, the relevant information about my platform is

  • Windows 7 x64
  • R-3.5.1, Rstudio-1.1.423
  • Rcpp-0.12.19, RcppArmadillo-0.9.100.5.0
  • roxygen2-6.1.1
Jablonski answered 6/12, 2018 at 0:12 Comment(0)
W
9

That is, as best as I can tell, roxygen2 issue ticket #771 which I filed on August 3, and which is still unresolved. Despite the roxygen2 team closing it. Feel free to follow-up there.

If one use roxygen2 6.0.1 it works:

edd@rob:/tmp$ r -lRcppArmadillo -e'RcppArmadillo.package.skeleton(name = "prac_181206", example_code = FALSE)'

Calling kitten to create basic package.
Creating directories ...
Creating DESCRIPTION ...
Creating NAMESPACE ...
Creating Read-and-delete-me ...
Saving functions and data ...
Making help files ...
Done.
Further steps are described in './prac_181206/Read-and-delete-me'.

Adding pkgKitten overrides.
Deleted 'Read-and-delete-me'.
Done.

Consider reading the documentation for all the packaging details.
A good start is the 'Writing R Extensions' manual.

And run 'R CMD check'. Run it frequently. And think of those kittens.


Adding RcppArmadillo settings
 >> added Imports: Rcpp
 >> added LinkingTo: Rcpp, RcppArmadillo
 >> added useDynLib and importFrom directives to NAMESPACE
 >> added Makevars file with Rcpp settings
 >> added Makevars.win file with RcppArmadillo settings
edd@rob:/tmp$ cd prac_181206/
edd@rob:/tmp/prac_181206$ roxy.r 
** Using cached version 6.0.1 of roxygen2.
First time using roxygen2. Upgrading automatically...
Updating roxygen version in /tmp/prac_181206/DESCRIPTION
Loading required package: Rcpp
edd@rob:/tmp/prac_181206$ 

where roxy.r is this simple wrapper that hard-wires roxygen2 6.0.1.

Watchband answered 6/12, 2018 at 1:14 Comment(4)
I appreciate your comment. It's very good to know this is an error not only for me. I'll follow the issue up there. ThanksJablonski
You're welcome, and I agree that it would be good to follow up over there as you also seem to see this is a regression from roxygen2 6.0.1 to the current version. The roxygen2 team is dismissive as they only seem to care about use from devtools etc which is not the workflow I use.Watchband
It may be best to file a new issue as I can't seem to re-open the ones I was involved in: #771, #776, #822.Watchband
Okay, I will open a new issue there :)Jablonski

© 2022 - 2024 — McMap. All rights reserved.