New Error: 'C:/rtools40/usr/mingw_/bin/g++' not found; Allocating Large Vector

Hello all, I just today updated to R 4.0, RTools40, and the latest version of RStudio. After installing those, I also installed the rstan and StanHeaders packages from source. I’m now running into some curious issues trying to fit models in STAN, which worked fine previously.

When running any model, I get the following issue:

Error: cannot allocate vector of size 12186.1 Gb
In addition: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
‘C:/rtools40/usr/mingw_/bin/g++’ not found

The “vector size” varies depending on the specific model I am attempting to fit, but the other error line is ubiquitous. I never had issues running these models before and there shouldn’t be anything remotely approaching that size involved in any of them, so I’m not sure what the issue is.

Operating System: Windows 10 Enterprise 64-bit
RStan Version: 2.21.2

Output of writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars")))

Error in file(con, “r”) : cannot open the connection
In addition: Warning message:
In file(con, “r”) :
cannot open file ‘C:\Users\karter.harmon\Documents/.R/Makevars’: No such file or directory

Output of devtools::session_info("rstan")

  • Session info -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    setting value
    version R version 4.0.2 (2020-06-22)
    os Windows 10 x64
    system x86_64, mingw32
    ui RStudio
    language (EN)
    collate English_United States.1252
    ctype English_United States.1252
    tz America/Los_Angeles
    date 2020-09-22

  • Packages ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    ! package * version date lib source
    assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.2)
    backports 1.1.10 2020-09-15 [1] CRAN (R 4.0.2)
    BH 1.72.0-3 2020-01-08 [1] CRAN (R 4.0.0)
    callr 3.4.4 2020-09-07 [1] CRAN (R 4.0.2)
    checkmate 2.0.0 2020-02-06 [1] CRAN (R 4.0.2)
    cli 2.0.2 2020-02-28 [1] CRAN (R 4.0.2)
    colorspace 1.4-1 2019-03-18 [1] CRAN (R 4.0.2)
    crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.2)
    curl 4.3 2019-12-02 [1] CRAN (R 4.0.2)
    desc 1.2.0 2018-05-01 [1] CRAN (R 4.0.2)
    digest 0.6.25 2020-02-23 [1] CRAN (R 4.0.2)
    ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.2)
    evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.2)
    fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.2)
    farver 2.0.3 2020-01-16 [1] CRAN (R 4.0.2)
    ggplot2 * 3.3.2 2020-06-19 [1] CRAN (R 4.0.2)
    glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.2)
    gridExtra 2.3 2017-09-09 [1] CRAN (R 4.0.2)
    gtable 0.3.0 2019-03-25 [1] CRAN (R 4.0.2)
    inline 0.3.16 2020-09-06 [1] CRAN (R 4.0.2)
    isoband 0.2.2 2020-06-20 [1] CRAN (R 4.0.2)
    jsonlite 1.7.1 2020-09-07 [1] CRAN (R 4.0.2)
    labeling 0.3 2014-08-23 [1] CRAN (R 4.0.0)
    lattice * 0.20-41 2020-04-02 [1] CRAN (R 4.0.2)
    lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.2)
    loo 2.3.1 2020-07-14 [1] CRAN (R 4.0.2)
    magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.2)
    MASS 7.3-51.6 2020-04-26 [1] CRAN (R 4.0.2)
    Matrix 1.2-18 2019-11-27 [1] CRAN (R 4.0.2)
    matrixStats 0.56.0 2020-03-13 [1] CRAN (R 4.0.2)
    mgcv 1.8-31 2019-11-09 [1] CRAN (R 4.0.2)
    munsell 0.5.0 2018-06-12 [1] CRAN (R 4.0.2)
    nlme 3.1-148 2020-05-24 [1] CRAN (R 4.0.2)
    pillar 1.4.6 2020-07-10 [1] CRAN (R 4.0.2)
    pkgbuild 1.1.0 2020-07-13 [1] CRAN (R 4.0.2)
    pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.2)
    pkgload 1.1.0 2020-05-29 [1] CRAN (R 4.0.2)
    praise 1.0.0 2015-08-11 [1] CRAN (R 4.0.2)
    prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.2)
    processx 3.4.4 2020-09-03 [1] CRAN (R 4.0.2)
    ps 1.3.4 2020-08-11 [1] CRAN (R 4.0.2)
    R6 2.4.1 2019-11-12 [1] CRAN (R 4.0.2)
    RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 4.0.0)
    Rcpp 1.0.5 2020-07-06 [1] CRAN (R 4.0.2)
    RcppEigen 0.3.3.7.0 2019-11-16 [1] CRAN (R 4.0.2)
    D RcppParallel 5.0.2 2020-06-24 [1] CRAN (R 4.0.2)
    rlang 0.4.7 2020-07-09 [1] CRAN (R 4.0.2)
    rprojroot 1.3-2 2018-01-03 [1] CRAN (R 4.0.2)
    rstan * 2.21.2 2020-07-27 [1] CRAN (R 4.0.2)
    rstudioapi 0.11 2020-02-07 [1] CRAN (R 4.0.2)
    scales 1.1.1 2020-05-11 [1] CRAN (R 4.0.2)
    StanHeaders * 2.21.0-6 2020-08-16 [1] CRAN (R 4.0.2)
    testthat 2.3.2 2020-03-02 [1] CRAN (R 4.0.2)
    tibble * 3.0.3 2020-07-10 [1] CRAN (R 4.0.2)
    utf8 1.1.4 2018-05-24 [1] CRAN (R 4.0.2)
    V8 3.2.0 2020-06-19 [1] CRAN (R 4.0.2)
    vctrs 0.3.4 2020-08-29 [1] CRAN (R 4.0.2)
    viridisLite 0.3.0 2018-02-01 [1] CRAN (R 4.0.2)
    withr 2.3.0 2020-09-22 [1] CRAN (R 4.0.2)

[1] C:/Users/karter.harmon/Documents/R/R-4.0.2/library

D – DLL MD5 mismatch, broken installation.

That looks to me like the issue is with the ‘RcppParallel’ package. I’ve reinstalled it but doesn’t seem to be making a difference.

I am in a bit over my head here so any help is greatly appreciated. Thanks!

The g++ not found thing is a warning that is safe to ignore.

The cannot allocate vector has come up before but I’ve forgotten the exact solutions.

Some people have luck clearing out R configuration files: Cannot resolve the "cannot allocate vector of size … " error and here’s someone who got past these problems by recompiling their models: Error: cannot allocate vector of size 17348.7 Gb (you can ensure this happens by changing the model file name to make sure and not get a cached binary).

Give those a shot and report back

Thanks for the quick response. I will try out the solutions in those threads and update with the results. Fingers crossed!

OK some progress…It seems like deleting the .Rhistory and .rds files in my working directories got the models to compile again.

I’ll note that I did try every other solution offered in the linked threads, including:
-Changing the name of the Makevars.win file
-Following the RTools40 setup instructions for the wiki
-Removing all references to RTools35 in the various directories
-Adding code to the Makevars.win file
-Running Sys.setenv(RTOOLS40_HOME = “C:/rtools40”)
-Changing the name of the model to something else

None of which made a difference. But it seems like deleting the .Rhistory and .rds files did allow the models to compile.

I’m getting a different error now on one of the models but I think it is a separate issue so I will mark the above as the solution for the large vector issue.

The error I’m getting now is:

Error in open.connection(con, open = mode) :
Could not resolve host: github-production-release-asset-2e65be.s3.amazonaws.com

Which I should probably research or make another topic for.

Thanks again!

Ouch. Thanks for reporting back. Were these like the R session rds files?

Oof. That is not fun either. The new rstan tries to download a new parser that we’re testing for the next rstan release. You can opt out of this with:

rstan_options(javascript = FALSE)

and then try to build your model again. I thought it should still work even if the download fails though. Give that a try?

Hi Karter,

The reason that deleting the .rds files worked (and the rest didn’t) was because they contained the code compiled by the old version of RTools. When R tries to run that code, but assumes that it was compiled by the new version of RTools, you get this vector allocation error.

rstan_options(javascript = FALSE)

resolved the open.connection error. Thanks!!