Problems with package using rstan/rstantools

If your question relates to installation please provide the following information:

  • Operating System: Windows 10
  • RStan Version:
  • Output of writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars"))):
CXX14FLAGS=-O3 -mtune=native -Wno-unused-variable -Wno-unused-function -fPIC
CXX11FLAGS=-O3 -mtune=native
CXX14 = $(BINPREF)g++ -m$(WIN) -std=c++1y
  • Output of devtools::session_info("rstan"):
- Session info -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.6.0 (2019-04-26)
 os       Windows 10 x64              
 system   x86_64, mingw32             
 ui       RStudio                     
 language (EN)                        
 collate  Norwegian Bokmål_Norway.1252
 ctype    Norwegian Bokmål_Norway.1252
 tz       Europe/Berlin               
 date     2019-10-22                  

- Packages -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 package      * version   date       lib source        
 assertthat     0.2.1     2019-03-21 [1] CRAN (R 3.6.1)
 backports      1.1.5     2019-10-02 [1] CRAN (R 3.6.1)
 BH             1.69.0-1  2019-01-07 [1] CRAN (R 3.6.0)
 callr          3.3.2     2019-09-22 [1] CRAN (R 3.6.1)
 checkmate      1.9.4     2019-07-04 [1] CRAN (R 3.6.1)
 cli            1.1.0     2019-03-19 [1] CRAN (R 3.6.1)
 colorspace     1.4-1     2019-03-18 [1] CRAN (R 3.6.1)
 crayon         1.3.4     2017-09-16 [1] CRAN (R 3.6.1)
 desc           1.2.0     2018-05-01 [1] CRAN (R 3.6.1)
 digest         0.6.21    2019-09-20 [1] CRAN (R 3.6.1)
 ellipsis       0.3.0     2019-09-20 [1] CRAN (R 3.6.1)
 fansi          0.4.0     2018-10-05 [1] CRAN (R 3.6.1)
 ggplot2        3.2.1     2019-08-10 [1] CRAN (R 3.6.1)
 glue           1.3.1     2019-03-12 [1] CRAN (R 3.6.1)
 gridExtra      2.3       2017-09-09 [1] CRAN (R 3.6.1)
 gtable         0.3.0     2019-03-25 [1] CRAN (R 3.6.1)
 inline         0.3.15    2018-05-18 [1] CRAN (R 3.6.1)
 labeling       0.3       2014-08-23 [1] CRAN (R 3.6.0)
 lattice        0.20-38   2018-11-04 [1] CRAN (R 3.6.0)
 lazyeval       0.2.2     2019-03-15 [1] CRAN (R 3.6.1)
 loo            2.1.0     2019-03-13 [1] CRAN (R 3.6.1)
 magrittr       1.5       2014-11-22 [1] CRAN (R 3.6.1)
 MASS           7.3-51.4  2019-03-31 [1] CRAN (R 3.6.0)
 Matrix         1.2-17    2019-03-22 [1] CRAN (R 3.6.0)
 matrixStats    0.55.0    2019-09-07 [1] CRAN (R 3.6.1)
 mgcv           1.8-28    2019-03-21 [1] CRAN (R 3.6.0)
 munsell        0.5.0     2018-06-12 [1] CRAN (R 3.6.1)
 nlme           3.1-141   2019-08-01 [1] CRAN (R 3.6.1)
 pillar         1.4.2     2019-06-29 [1] CRAN (R 3.6.1)
 pkgbuild       1.0.6     2019-10-09 [1] CRAN (R 3.6.0)
 pkgconfig      2.0.3     2019-09-22 [1] CRAN (R 3.6.1)
 plyr           1.8.4     2016-06-08 [1] CRAN (R 3.6.1)
 prettyunits    1.0.2     2015-07-13 [1] CRAN (R 3.6.1)
 processx       3.4.1     2019-07-18 [1] CRAN (R 3.6.1)
 ps             1.3.0     2018-12-21 [1] CRAN (R 3.6.1)
 R6             2.4.0     2019-02-14 [1] CRAN (R 3.6.1)
 RColorBrewer   1.1-2     2014-12-07 [1] CRAN (R 3.6.0)
 Rcpp           1.0.2     2019-07-25 [1] CRAN (R 3.6.1)
 RcppEigen      0.3.3.5.0 2018-11-24 [1] CRAN (R 3.6.1)
 reshape2       1.4.3     2017-12-11 [1] CRAN (R 3.6.1)
 rlang          0.4.0     2019-06-25 [1] CRAN (R 3.6.1)
 rprojroot      1.3-2     2018-01-03 [1] CRAN (R 3.6.1)
 rstan          2.19.2    2019-07-09 [1] CRAN (R 3.6.1)
 scales         1.0.0     2018-08-09 [1] CRAN (R 3.6.1)
 StanHeaders    2.19.0    2019-09-07 [1] CRAN (R 3.6.1)
 stringi        1.4.3     2019-03-12 [1] CRAN (R 3.6.0)
 stringr        1.4.0     2019-02-10 [1] CRAN (R 3.6.1)
 tibble         2.1.3     2019-06-06 [1] CRAN (R 3.6.1)
 utf8           1.1.4     2018-05-24 [1] CRAN (R 3.6.1)
 vctrs          0.2.0     2019-07-05 [1] CRAN (R 3.6.1)
 viridisLite    0.3.0     2018-02-01 [1] CRAN (R 3.6.1)
 withr          2.1.2     2018-03-15 [1] CRAN (R 3.6.1)
 zeallot        0.1.0     2018-01-28 [1] CRAN (R 3.6.1)

After following the instructions for building a package with rstantools i can successfully execute

pkgbuild::compile_dll()
roxygen2::roxygenize()

(I generally do not have problems compiling models with rstan, my problem is making a package with a stan model)

but when I try
install.packages("../spolr", repos = NULL, type = "source")

I get the following error message:

* installing *source* package 'spolr' ...
** using staged installation
** libs

*** arch - i386
C:\Rtools\mingw_32\bin\nm.exe: RcppExports.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_sbetabin.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_sbinomial.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_sgauss.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_slogreg.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_snegbin.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: RcppExports.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_sbetabin.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_sbinomial.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_sgauss.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_slogreg.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_snegbin.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_spolr.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_spolrn.o: File format not recognized
C:/Rtools/mingw_32/bin/g++ -m32 -std=c++1y -shared -s -static-libgcc -o spolr.dll tmp.def RcppExports.o stanExports_sbetabin.o stanExports_sbinomial.o stanExports_sgauss.o stanExports_slogreg.o stanExports_snegbin.o stanExports_spolr.o stanExports_spolrn.o -LC:/PROGRA~1/R/R-36~1.0/bin/i386 -lR
RcppExports.o: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
C:\Rtools\mingw_32\bin\nm.exe: RcppExports.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_sbetabin.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_sbinomial.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_sgauss.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_slogreg.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_snegbin.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_spolr.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_spolrn.o: File format not recognized
C:/Rtools/mingw_32/bin/g++ -m32 -std=c++1y -shared -s -static-libgcc -o spolr.dll tmp.def RcppExports.o stanExports_sbetabin.o stanExports_sbinomial.o stanExports_sgauss.o stanExports_slogreg.o stanExports_snegbin.o stanExports_spolr.o stanExports_spolrn.o -LC:/PROGRA~1/R/R-36~1.0/bin/i386 -lR
RcppExports.o: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'spolr'
* removing 'C:/Program Files/R/R-3.6.0/library/spolr'
* restoring previous 'C:/Program Files/R/R-3.6.0/library/spolr'
Warning in file.copy(lp, dirname(pkgdir), recursive = TRUE, copy.date = TRUE) :
C:\Rtools\mingw_32\bin\nm.exe: RcppExports.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_sbetabin.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_sbinomial.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_sgauss.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_slogreg.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_snegbin.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_spolr.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_spolrn.o: File format not recognized
C:/Rtools/mingw_32/bin/g++ -m32 -std=c++1y -shared -s -static-libgcc -o spolr.dll tmp.def RcppExports.o stanExports_sbetabin.o stanExports_sbinomial.o stanExports_sgauss.o stanExports_slogreg.o stanExports_snegbin.o stanExports_spolr.o stanExports_spolrn.o -LC:/PROGRA~1/R/R-36~1.0/bin/i386 -lR
RcppExports.o: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'spolr'
* removing 'C:/Program Files/R/R-3.6.0/library/spolr'
* restoring previous 'C:/Program Files/R/R-3.6.0/library/spolr'
Warning in file.copy(lp, dirname(pkgdir), recursive = TRUE, copy.date = TRUE) :
  problem copying C:\Program Files\R\R-3.6.0\library\00LOCK-spolr\spolr\libs\x64\spolr.dll to C:\Program Files\R\R-3.6.0\library\spolr\libs\x64\spolr.dll: Permission denied
Warning in install.packagesC:\Rtools\mingw_32\bin\nm.exe: RcppExports.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_sbetabin.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_sbinomial.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_sgauss.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_slogreg.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_snegbin.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_spolr.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanExports_spolrn.o: File format not recognized
C:/Rtools/mingw_32/bin/g++ -m32 -std=c++1y -shared -s -static-libgcc -o spolr.dll tmp.def RcppExports.o stanExports_sbetabin.o stanExports_sbinomial.o stanExports_sgauss.o stanExports_slogreg.o stanExports_snegbin.o stanExports_spolr.o stanExports_spolrn.o -LC:/PROGRA~1/R/R-36~1.0/bin/i386 -lR
RcppExports.o: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'spolr'
* removing 'C:/Program Files/R/R-3.6.0/library/spolr'
* restoring previous 'C:/Program Files/R/R-3.6.0/library/spolr'
Warning in file.copy(lp, dirname(pkgdir), recursive = TRUE, copy.date = TRUE) :
  problem copying C:\Program Files\R\R-3.6.0\library\00LOCK-spolr\spolr\libs\x64\spolr.dll to C:\Program Files\R\R-3.6.0\library\spolr\libs\x64\spolr.dll: Permission denied
Warning in install.packages :
  installation of package ‘../spolr’ had non-zero exit status

Next I tried to remove all files except the .dll file from the src directory. But this also doesn’t work, and I get the following error messages:

In addition, I see that install.packages generates two new folders (src-i386 and srcx64), which are not created when I am trying to build the package with devtools::install(local=FALSE, quick = TRUE). Building with devtools worked previously, but now I am getting an error
Error: 1 components of `...` were not used., which seems to come from a problem when using the ellipsis package, which generates the following message:

<error>
message: 1 components of `...` were not used.

We detected these problematic arguments:
* `local`

Did you misspecify an argument?
class:   `rlib_error_dots_unused`
backtrace:
 1. devtools::install(local = FALSE, quick = TRUE)
 3. ellipsis:::action_dots(...)
Call `rlang::last_trace()` to see the full backtrace

I solved this problem, How do I delete this post?

If you believe there is nothing to be learned from your solution, I can delete the topic as a moderator. If there is however at least a little piece of knowledge someone else might find helpful, I would prefer if you share it as an answer (obviously you are not obliged to do it, so if you do not have time/energy to put it into writing, this is OK as well)

I don’t think I fully understand what the problem was, even if I can make it compile reliably now.

Here is my reconstruction of what happened:

  • pkgbuild::compile_dll() generates a folder “src” which includes some files with then ending “.o”
  • the presence of such files makes the compilation fail
  • if I remove all files in src that end with “.o” then I can compile with install.packages
  • if I remove all files in src that end with “.o” and try to install with devtools::install_github this fails, apparently because of problems with the ellipses and/or rlang packages.

I did not investigate the problem with install_github further, because I got it to work with install.packages (which is the approach recommended in the rstantools vignette) and because I am uncertain if the problem is general, or specific to the package versions I have installed (I updated all packages to the most recent version).

4 Likes