Package builds, won't install with R 4.0

Hi,

I'm the maintainer of a fork of the rtree package: https://github.com/akoyabio/rtree. I'm getting the error below when building the package on Windows 10 with R 4.0. The package seems to build OK but it fails to install. The same code builds and installs without error with R 3.6.3. I'm at a loss of where to start with this. Any hints of what the problem might be or how to debug it greatly appreciated!

I have RTools 4.0. The package uses Rcpp, I have version 1.0.4.6 installed.

Thanks for any help!
Kent

==> Rcmd.exe INSTALL --preclean --no-multiarch --with-keep.source rtree

Loading C:\Users\kjohnson\Documents\Rprofile.site 
* installing to library 'C:/Program Files/R/Library/4.0'
* installing *source* package 'rtree' ...
** using staged installation
** libs
C:/RTools/mingw_64/bin/g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-4.0.0/include" -DNDEBUG  -I'C:/Program Files/R/Library/4.0/Rcpp/include' -I'C:/Program Files/R/Library/4.0/BH/include'        -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c RcppExports.cpp -o RcppExports.o
C:/RTools/mingw_64/bin/g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-4.0.0/include" -DNDEBUG  -I'C:/Program Files/R/Library/4.0/Rcpp/include' -I'C:/Program Files/R/Library/4.0/BH/include'        -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c rtree.cpp -o rtree.o
C:/RTools/mingw_64/bin/g++ -std=gnu++11 -shared -s -static-libgcc -o rtree.dll tmp.def RcppExports.o rtree.o -LC:/PROGRA~1/R/R-4.0.0/bin/x64 -lR
installing to C:/Program Files/R/Library/4.0/00LOCK-rtree/00new/rtree/libs/x64
** R
** byte-compile and prepare package for lazy loading
Loading C:\Users\kjohnson\Documents\Rprofile.site 
** help
*** installing help indices
  converting help for package 'rtree'
    RTree                                   html  
    countWithinDistance                     html      finding HTML links ... done

    knn                                     html  
    withinDistance                          html  
** building package indices
Loading C:\Users\kjohnson\Documents\Rprofile.site 
** testing if installed package can be loaded from temporary location
Loading C:\Users\kjohnson\Documents\Rprofile.site 
ERROR: loading failed
* removing 'C:/Program Files/R/Library/4.0/rtree'

Exited with status 1.
1 Like

What do you have defined in C:\Users\kjohnson\Documents\Rprofile.site? It's possible this could be causing the issue. For example, if you have anything specific to the R 3.x series, it could cause problems with R 4.0.

Great, that rules that out.

This looks like it is failing the staged install check. From Writing R Extensions:

The ‘StagedInstall’ logical field controls if package installation is ‘staged’, that is done to a temporary location and moved to the final location when successfully completed. This field was introduced in R 3.6.0 and it true by default: it is considered to be a temporary measure which may be withdrawn in future.

Thus try adding the following field to the DESCRIPTION file and re-installing:

StagedInstall: FALSE

OK, problem seems to be that I was using the wrong version of RTools. I'm struggling to get RStudio / RCmd to use the correct version but hopefully that is the problem. Thank you @jdblischak for taking a look and trying the build.

1 Like

Ah, yes, that'll do it. R 4.0.0 requires the new rtools40. Unlike previous versions of Rtools, this one requires manually adding it to PATH in .Renviron.

Since you've solved your issue, could you please select your answer as the solution?

FAQ: How do I mark a solution?

Thanks, Rprofile.site is pretty innocuous:

cat("Loading", Sys.getenv('R_PROFILE'), "\n")

# Show stack trace of errors
options(showErrorCalls=T)

# Use multiple CPUs for source package installs
options(Ncpus=2)

# No message on library(tidyverse)
options(tidyverse.quiet = TRUE)

If I rename .Rprofile.site so it is not loaded, I get the same error:

** testing if installed package can be loaded from temporary location
ERROR: loading failed
* removing 'C:/Program Files/R/Library/4.0/rtree'

Exited with status 1.
1 Like

Here is another hint - devtools::load_all gives this error:

> devtools::load_all(".")
Loading rtree
Error in Rcpp::loadModule(module = "rtreecpp", what = TRUE, env = ns,  : 
  Unable to load module "rtreecpp": cannot allocate vector of size 11449.0 Gb
> traceback()
6: stop(gettextf("Unable to load module \"%s\": %s", as(module, 
       "character"), loadM$message))
5: Rcpp::loadModule(module = "rtreecpp", what = TRUE, env = ns, 
       loadNow = TRUE)
4: action(nsenv)
3: run_ns_load_actions(package)
2: pkgload::load_all(path = path, reset = reset, recompile = recompile, 
       export_all = export_all, helpers = helpers, quiet = quiet, 
       ...)
1: devtools::load_all(".")

AFAIK I don't explicitly allocate anything on package load, certainly not 11 TB...

1 Like

I see. So the issue isn't that it can't load from a temporary directory, it's that it can't load at all.

I was able to load the package on Windows 10 with R 4.0:

devtools::load_all(".")
Loading rtree
Re-compiling rtree
-  installing *source* package 'rtree' ... (391ms)
   ** using non-staged installation
   ** libs
   "C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.0/include" -DNDEBUG  -I'C:/Users/john/Documents/R/win-library/4.0/Rcpp/include' -I'C:/Users/john/Documents/R/win-library/4.0/BH/include'        -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always -c RcppExports.cpp -o RcppExports.o
   "C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.0/include" -DNDEBUG  -I'C:/Users/john/Documents/R/win-library/4.0/Rcpp/include' -I'C:/Users/john/Documents/R/win-library/4.0/BH/include'        -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always -c rtree.cpp -o rtree.o
   In file included from C:/Users/john/Documents/R/win-library/4.0/BH/include/boost/geometry/core/closure.hpp:22
                    from C:/Users/john/Documents/R/win-library/4.0/BH/include/boost/geometry/geometry.hpp:25
                    from C:/Users/john/Documents/R/win-library/4.0/BH/include/boost/geometry.hpp:17
                    from rtree.cpp:10
   C:/Users/john/Documents/R/win-library/4.0/BH/include/boost/mpl/assert.hpp:194:21:warning: necessary parentheses in declaration of 'assert_arg-Wparentheses
    failed ************ (:************
                        ^
   C:/Users/john/Documents/R/win-library/4.0/BH/include/boost/mpl/assert.hpp:199:21:warning: necessary parentheses in declaration of 'assert_not_arg-Wparentheses
    failed ************ (::mpl::not_::************
                        ^

==thousands of lines omitted==

C:/rtools40/mingw64/bin/g++ -std=gnu++11 -shared -s -static-libgcc -o rtree.dll tmp.def RcppExports.o rtree.o -LC:/PROGRA~1/R/R-40~1.0/bin/x64 -lR
installing to C:/Users/john/AppData/Local/Temp/RtmpwJGfdJ/devtools_install_36785218801/rtree/libs/x64

  • DONE (rtree)
devtools::build(".")
√  checking for file 'C:\Users\john\repos\rtree/DESCRIPTION' ...
-  preparing 'rtree': (423ms)
√  checking DESCRIPTION meta-information
-  cleaning src
-  checking for LF line-endings in source and make files and shell scripts
-  checking for empty or unneeded directories
-  building 'rtree_0.1.0.tar.gz'
[1] "C:/Users/john/repos/rtree_0.1.0.tar.gz"
devtools::install(".")
√  checking for file 'C:\Users\john\repos\rtree/DESCRIPTION' ...
-  preparing 'rtree':
√  checking DESCRIPTION meta-information ... 
-  cleaning src
-  checking for LF line-endings in source and make files and shell scripts
-  checking for empty or unneeded directories
-  building 'rtree_0.1.0.tar.gz'

Running "C:/PROGRA~1/R/R-40~1.0/bin/x64/Rcmd.exe" INSTALL
"C:\Users\john\AppData\Local\Temp\RtmpwJGfdJ/rtree_0.1.0.tar.gz"
--install-tests

  • installing to library 'C:/Users/john/Documents/R/win-library/4.0'
  • installing source package 'rtree' ...
    ** using non-staged installation
    ** libs
    "C:/rtools40/mingw64/bin/"g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-40~1.0/include" -DNDEBUG -I'C:/Users/john/Documents/R/win-library/4.0/Rcpp/include' -I'C:/Users/john/Documents/R/win-library/4.0/BH/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c RcppExports.cpp -o RcppExports.o
    "C:/rtools40/mingw64/bin/"g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-40~1.0/include" -DNDEBUG -I'C:/Users/john/Documents/R/win-library/4.0/Rcpp/include' -I'C:/Users/john/Documents/R/win-library/4.0/BH/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c rtree.cpp -o rtree.o
    In file included from C:/Users/john/Documents/R/win-library/4.0/BH/include/boost/geometry/core/closure.hpp:22,
    from C:/Users/john/Documents/R/win-library/4.0/BH/include/boost/geometry/geometry.hpp:25,
    from C:/Users/john/Documents/R/win-library/4.0/BH/include/boost/geometry.hpp:17,
    from rtree.cpp:10:
    C:/Users/john/Documents/R/win-library/4.0/BH/include/boost/mpl/assert.hpp:194:21: warning: unnecessary parentheses in declaration of 'assert_arg' [-Wparentheses]
    failed ************ (Pred::************
    ^
    C:/Users/john/Documents/R/win-library/4.0/BH/include/boost/mpl/assert.hpp:199:21: warning: unnecessary parentheses in declaration of 'assert_not_arg' [-Wparentheses]
    failed ************ (boost::mpl::not_::************
    ^

==thousands of lines omitted==

C:/rtools40/mingw64/include/c++/8.3.0/bits/stl_pair.h:208:12: note: 'struct std::pair<boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian>, unsigned int>' declared here
struct pair
^~~~
C:/rtools40/mingw64/bin/g++ -std=gnu++11 -shared -s -static-libgcc -o rtree.dll tmp.def RcppExports.o rtree.o -LC:/PROGRA~1/R/R-40~1.0/bin/x64 -lR
installing to C:/Users/john/Documents/R/win-library/4.0/rtree/libs/x64
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
'rtree'rting help for package finding HTML links ...
done
|Tree html

  • countWithinDistance html
    | knn html
  • withinDistance html
    ** building package indices
    ** testing if installed package can be loaded
  • DONE (rtree)
sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base

other attached packages:
[1] rtree_0.1.0

loaded via a namespace (and not attached):
[1] Rcpp_1.0.4.6 rstudioapi_0.11 magrittr_1.5
[4] usethis_1.6.0 devtools_2.3.0 pkgload_1.0.2
[7] R6_2.4.1 rlang_0.4.5 BH_1.72.0-3
[10] fansi_0.4.1 tools_4.0.0 pkgbuild_1.0.7
[13] packrat_0.5.0 sessioninfo_1.1.1 cli_2.0.2
[16] withr_2.2.0 ellipsis_0.3.0 remotes_2.1.1
[19] assertthat_0.2.1 digest_0.6.25 rprojroot_1.3-2
[22] crayon_1.3.4 processx_3.4.2 callr_3.4.3
[25] codetools_0.2-16 fs_1.4.1 ps_1.3.2
[28] testthat_2.3.2 memoise_1.1.0 glue_1.4.0
[31] compiler_4.0.0 desc_1.2.0 backports_1.1.6
[34] prettyunits_1.1.1

No, that doesn't help. The output is nearly the same:

==> Rcmd.exe INSTALL --preclean --no-multiarch --with-keep.source rtree

* installing to library 'C:/Program Files/R/Library/4.0'
* installing *source* package 'rtree' ...
** using non-staged installation via StagedInstall field
** libs
<snip compile steps>
** building package indices
** testing if installed package can be loaded
ERROR: loading failed
* removing 'C:/Program Files/R/Library/4.0/rtree'

Exited with status 1.
1 Like