Rstantools rstan_package_skeleton() failing with "Error in getDLLRegisteredRoutines.DLLInfo"

#1

I’m trying to follow the vignette on creating a package that depends on RStan: http://mc-stan.org/rstantools/articles/minimal-rstan-package.html

I’m able to install rstantools, but there’s an error in running rstan_package_skeleton(). I don’t know how close it is to being a well-formed package. Some help?

Here’s what happens when I run it:

> rstan_package_skeleton(path="rpkg")
Creating package skeleton for package: rpkg
Running usethis::create_package ...
New project 'rpkg' is nested inside an existing project '.'. This is rarely a good idea. Do you wish to create anyway?
1: Not now
2: No
3: I agree

Selection: 3
✔ Setting active project to '/Users/daniel/dev/merck-pilot/rpkg'
✔ Creating 'R/'
✔ Creating 'man/'
✔ Writing 'DESCRIPTION'
✔ Writing 'NAMESPACE'
✔ Creating 'tools/'
✔ Creating 'src/'
✔ Creating 'src/stan_files/'
✔ Creating 'src/stan_files/chunks/'
✔ Creating 'inst/'
✔ Creating 'inst/include/'
Updating R directory ...
Adding .travis.yml file ...
Updating DESCRIPTION with necessary dependencies ...
Updating NAMESPACE ...
Writing NAMESPACE
Error in getDLLRegisteredRoutines.DLLInfo(dll, addNames = FALSE) : 
  must specify DLL via a “DLLInfo” object. See getLoadedDLLs()

I’ve also verified that this happens on another Mac.

Is there a known work-around? Should I file a bug report? Is there more information I can provide?

cc: @jonah @bgoodri


  • Mac OS/X 10.14.1
  • RStan Version: 2.18.2
  • rstantools version: rstantools_1.5.1
  • Output of writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars")))
  • Output of devtools::session_info("rstan")
> devtools::session_info("rstan")
─ Session info ───────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.5.1 (2018-07-02)
 os       macOS  10.14.1              
 system   x86_64, darwin15.6.0        
 ui       X11                         
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       America/New_York            
 date     2018-12-04                  

─ Packages ───────────────────────────────────────────────────────────────────
 package      * version   date       lib source        
 assertthat     0.2.0     2017-04-11 [1] CRAN (R 3.5.0)
 backports      1.1.2     2017-12-13 [1] CRAN (R 3.5.0)
 base64enc      0.1-3     2015-07-28 [1] CRAN (R 3.5.0)
 BH             1.66.0-1  2018-02-13 [1] CRAN (R 3.5.0)
 callr          3.0.0     2018-08-24 [1] CRAN (R 3.5.0)
 cli            1.0.1     2018-09-25 [1] CRAN (R 3.5.0)
 colorspace     1.3-2     2016-12-14 [1] CRAN (R 3.5.0)
 crayon         1.3.4     2017-09-16 [1] CRAN (R 3.5.0)
 desc           1.2.0     2018-05-01 [1] CRAN (R 3.5.0)
 digest         0.6.18    2018-10-10 [1] CRAN (R 3.5.0)
 fansi          0.4.0     2018-10-05 [1] CRAN (R 3.5.0)
 ggplot2      * 3.1.0     2018-10-25 [1] CRAN (R 3.5.0)
 glue           1.3.0     2018-07-17 [1] CRAN (R 3.5.0)
 gridExtra      2.3       2017-09-09 [1] CRAN (R 3.5.0)
 gtable         0.2.0     2016-02-26 [1] CRAN (R 3.5.0)
 inline         0.3.15    2018-05-18 [1] CRAN (R 3.5.0)
 labeling       0.3       2014-08-23 [1] CRAN (R 3.5.0)
 lattice        0.20-35   2017-03-25 [1] CRAN (R 3.5.1)
 lazyeval       0.2.1     2017-10-29 [1] CRAN (R 3.5.0)
 loo            2.0.0     2018-04-11 [1] CRAN (R 3.5.0)
 magrittr       1.5       2014-11-22 [1] CRAN (R 3.5.0)
 MASS           7.3-50    2018-04-30 [1] CRAN (R 3.5.1)
 Matrix         1.2-14    2018-04-13 [1] CRAN (R 3.5.1)
 matrixStats    0.54.0    2018-07-23 [1] CRAN (R 3.5.0)
 mgcv           1.8-24    2018-06-23 [1] CRAN (R 3.5.1)
 munsell        0.5.0     2018-06-12 [1] CRAN (R 3.5.0)
 nlme           3.1-137   2018-04-07 [1] CRAN (R 3.5.1)
 pillar         1.3.0     2018-07-14 [1] CRAN (R 3.5.0)
 pkgbuild       1.0.2     2018-10-16 [1] CRAN (R 3.5.0)
 plyr           1.8.4     2016-06-08 [1] CRAN (R 3.5.0)
 prettyunits    1.0.2     2015-07-13 [1] CRAN (R 3.5.0)
 processx       3.2.0     2018-08-16 [1] CRAN (R 3.5.0)
 ps             1.2.1     2018-11-06 [1] CRAN (R 3.5.0)
 R6             2.3.0     2018-10-04 [1] CRAN (R 3.5.0)
 RColorBrewer   1.1-2     2014-12-07 [1] CRAN (R 3.5.0)
 Rcpp         * 1.0.0     2018-11-07 [1] CRAN (R 3.5.0)
 RcppEigen      0.3.3.5.0 2018-11-24 [1] CRAN (R 3.5.0)
 reshape2       1.4.3     2017-12-11 [1] CRAN (R 3.5.0)
 rlang          0.3.0.1   2018-10-25 [1] CRAN (R 3.5.0)
 rprojroot      1.3-2     2018-01-03 [1] CRAN (R 3.5.0)
 rstan        * 2.18.2    2018-11-07 [1] CRAN (R 3.5.0)
 scales         1.0.0     2018-08-09 [1] CRAN (R 3.5.0)
 StanHeaders  * 2.18.0    2018-10-07 [1] CRAN (R 3.5.0)
 stringi        1.2.4     2018-07-20 [1] CRAN (R 3.5.0)
 stringr        1.3.1     2018-05-10 [1] CRAN (R 3.5.0)
 tibble         1.4.2     2018-01-22 [1] CRAN (R 3.5.0)
 utf8           1.1.4     2018-05-24 [1] CRAN (R 3.5.0)
 viridisLite    0.3.0     2018-02-01 [1] CRAN (R 3.5.0)
 withr          2.1.2     2018-03-15 [1] CRAN (R 3.5.0)

[1] /Library/Frameworks/R.framework/Versions/3.5/Resources/library
0 Likes

Problem running devtools::install() on simple rstan-based package
#2

Does it work if you specify the stan_files argument?

0 Likes

#3

No, it does not. Stops in exactly the same place.

More detail: I created a simple, valid model called intro.stan in the working directory. Then I called this:

rstan_package_skeleton("rpkg", stan_files="intro.stan")
0 Likes

#4

Some more detail… I dug into to the source and I’m finding that this message comes from this line:

> roxygen2::roxygenise(package.dir = DIR, clean = TRUE)
Writing NAMESPACE
Loading rpkg
Error in getDLLRegisteredRoutines.DLLInfo(dll, addNames = FALSE) : 
  must specify DLL via a “DLLInfo” object. See getLoadedDLLs()

I was able to run that outside of the rstan_package_skeleton() code and see it fail. Any suggestions?

0 Likes

#5

Yeah, roxygen2 changed in ways that broke a lot of people’s stuff. I would just try installing rstantools from GitHub

devtools::install_github("stan-dev/rstantools", ref = "dd1009c")

because we call roxygen2 less.

0 Likes

#6

Thanks, @bgoodri. I don’t know exactly what steps I took to fix it, but somehow I got it working.

0 Likes

#8

I’m running into the same problem as @syclik. Not when I run rstan_package_skeleton(), but when I run roxygen2::roxygenise(clean=TRUE) as on https://cran.r-project.org/web/packages/rstantools/vignettes/minimal-rstan-package.html

> roxygen2::roxygenise(clean=TRUE)
Updating roxygen version in /Users/name/GitHub/rpkg/DESCRIPTION
Writing NAMESPACE
Loading rpkg
Error in getDLLRegisteredRoutines.DLLInfo(dll, addNames = FALSE) : 
  must specify DLL via a “DLLInfo” object. See getLoadedDLLs()

The instructions at https://cran.r-project.org/web/packages/rstantools/vignettes/minimal-rstan-package.html thus no longer work. I understand this likely has to do with the roxygen2 updates, but I’m a bit at a loss right now how to get the package started without the skeleton, primarily because I don’t know how to create pre-compiled .stan programs.

0 Likes

#9

Have you tried the GitHub version?

remotes::install_github("stan-dev/rstantools", ref = "c3c59fb")

?

1 Like

#10

I had tried it with the ref = “dd1009c” that was posted above, and just now with the ref = “c3c59fb” that you just posted. Neither worked though. I just got the following error:

Updating roxygen version in /Users/name/GitHub/rstanlm/DESCRIPTION
Writing NAMESPACE
Loading rstanlm
Error in getDLLRegisteredRoutines.DLLInfo(dll, addNames = FALSE) : 
  must specify DLL via a “DLLInfo” object. See getLoadedDLLs()```
0 Likes

#11

Did you call rstan_package.skeleton again? It should avoid calling roxygen2 functions completely.

0 Likes

#12

The call to rstan_package_skeleton() works without a problem. It’s later in the tutorial when I’m asked to call roxygen2::roxygenise(clean=TRUE) under “Documentation”—about 3/4 of the way down the vignette. If I skip instead to the next step, devtools::install(local=FALSE), it doesn’t appear to compile the .stan file I added (not sure if that’s linked to the roxygen2 step).

0 Likes

#13

Is it on GitHub?

0 Likes

#14

Is my working through the vignette on GitHub? I’ve only done the following (where I get the error at the last step):

setwd("~/Github")

rstan_package_skeleton("rstanlm")

setwd("~/Github/rstanlm")

# Place lm.stan in rstanlm/src/stan_files/

# Place lm_stan.R in rstanlm/R/

roxygen2::roxygenise(clean=TRUE)
0 Likes

#15

No, I mean is your package on GitHub?

0 Likes

#16

Oh, sure, I just posted it here: https://bit.ly/2GoUtke

0 Likes

#17

This seems to be missing some of the files under the src/ directory.

Try it with

rstan_create_package("rstanlm", stan_files="lm.stan")
0 Likes

#18

Just tried this and I still ran into the same error unfortunately. The version where I use stan_files = "lm.stan" is up on Github as well at: https://bit.ly/2I6uLCF

0 Likes

#20

Going to answer my own question here, and it has to do with roxygen2 from what I can tell. But one needs to first call pkgbuild::compile_dll() before calling roxygen2::roxygenise(clean=TRUE).

The issue is documented here: https://github.com/klutometis/roxygen/issues/822#issuecomment-441425591

2 Likes

#21

I’m getting the same error, at the same point in the rstan_package_skeleton tutorial (following the steps, but using my own package name and files), and pkgbuild::compile_dll() does not work.

I’m using the ref = “c3c59fb" version of rstantools. It successfully created the package skeleton, and I moved two Stan files into src/stan_files (FWIW, it didn’t create this directory automatically, so I added it manually). I put one R function, with roxygen header formatted exactly as in the tutorial, into the R directory. roxygen2::roxygenise(clean=TRUE) fails as described above, but pkgbuild::compile_dll() gives the error:

Re-compiling CJStan 
-  installing *source* package 'CJStan' ...
   ** libs
   no DLL was created
   ERROR: compilation failed for package 'CJStan'
-  removing 'C:/Users/myname/AppData/Local/Temp/Rtmp6TZULL/devtools_install_34ec416f4026/CJStan'
   In R CMD INSTALL
 Error in (function (command = NULL, args = character(), error_on_status = TRUE,  : 
  System command error 

Any ideas?

0 Likes

#22

Is there a repository for it somewhere? It is probably easier for me to just make a PR that fixes it.

0 Likes