Modeling failed Warnings: 'C:/Users/R-34~1.3/rtools40/usr/mingw_/bin/g++' not found Errors: Multiple results for CXX14FLAGS found, something is wrong.FALSE

Short summary of the problem:
I have installed R and rstan on my laptop and I am running a stream metabolizer model . And I changed the default libPaths so I set things to install in the right directory. But I am still getting this error " Warning message: In metab_bayes(data = dat, specs(mm_name(“bayes”, err_proc_iid = FALSE), : Modeling failed Warnings: ‘C:/Users/R-34~1.3/rtools40/usr/mingw_/bin/g++’ not found Errors: Multiple results for CXX14FLAGS found, something is wrong.FALSE"
Any idea where this problem is coming from? I tried installing older versions of R and rstan that are compatible, and I also got the same error. I thought it was a version issue, but I am not sure at this stage? The error appears after I run the Bayesian model line below.

mm <- metab_bayes(data=dat,specs(mm_name('bayes', err_proc_iid=FALSE),
                                   n_cores=4, n_chains=5, burnin_steps=500, saved_steps=500)) 

The code and data are available (on http://usgs-r.github.io/streamMetabolizer/articles/get_started.html)

Installation information:

  • Operating System windows 10
  • 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 ‘\server\userhome\students4\My Documents/.R/Makevars’: No such file or directory

  • Output of devtools::session_info("rstan")
  • Session info ----------------------------------
    setting value
    version R version 4.0.3 (2020-10-10)
    os Windows 10 x64
    system x86_64, mingw32
    ui RStudio
    language (EN)
    collate English_United States.1252
    ctype English_United States.1252
    tz Australia/Perth
    date 2020-11-09

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

[1] C:/Users/R/R-4.0.3/library
[2] \server/userhome/students4/My Documents/R/win-library/4.0

D – DLL MD5 mismatch, broken installation.

Are you using a network mounted drive for R and / or R packages?

Yes, the default goes to the university server. But I changed by .libPaths for my packages installation, so every time I make sure I have the right folder by selecting it. I couldn’t have a way around this, cause I don’t have local admin rights on the C drive except for my user folder.

Try

Sys.setenv("R_REMOTES_NO_ERRORS_FROM_WARNINGS" = "true")
remotes::install_github("stan-dev/rstan", ref = "develop", subdir = "rstan/rstan")

I got this error
Error: Failed to install ‘rstan’ from GitHub:
Git does not seem to be installed on your system.
In addition: Warning message:
In utils::untar(tarfile, …) :
‘tar.exe -xf “C:\Users\AppData\Local\Temp\RtmpOci52S\file451c24de7d26.tar.gz” -C “C:/Users/AppData/Local/Temp/RtmpOci52S/remotes451ca356431”’ returned error code 1

Maybe

install.packages("git2r")

first.

That didn’t help, I am getting the same error as above :(

On a slightly different tack, can you post the outputs from:

Sys.getenv("PATH")
Sys.getenv("BINPREF")
readLines("~/.R/Makevars.win")
readLines("~/.Rprofile")
readLines("~/.Renviron")

Just to get more information about how things are configured

Sys.getenv(“PATH”)
[1] “C:\Users\R-3.4.3\rtools40\usr\bin;C:\Users\R\R-4.0.3\bin\x64;C:\ProgramData\Oracle\Java\javapath;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files\MATLAB\R2019b\runtime\win64;C:\Program Files\MATLAB\R2019b\bin;C:\Program Files\PuTTY;C:\Users\AppData\Local\Microsoft\WindowsApps;C:\Users\AppData\Local\GitHubDesktop\bin;C:\Users\R\Chrome driver;C:\Users\R-3.6.3\Rtools”
Sys.getenv(“BINPREF”)
[1] “”
readLines(“~/.R/Makevars.win”)
[1] “”
[2] “CXX14FLAGS=-O3 -march=corei7 -mtune=corei7”
[3] “CXX14 = (BINPREF)g++ -m(WIN) -std=c++1y”
[4] “CXX11FLAGS=-O3 -march=corei7 -mtune=corei7”
[5] “”
[6] “CXX14FLAGS=-O3 -march=corei7 -mtune=corei7”
[7] “CXX14 = (BINPREF)g++ -m(WIN) -std=c++1y”
[8] “CXX11FLAGS=-O3 -march=corei7 -mtune=corei7”
[9] “”
[10] “CXX14FLAGS=-O3 -march=corei7 -mtune=corei7”
[11] “CXX14 = (BINPREF)g++ -m(WIN) -std=c++1y”
[12] “CXX11FLAGS=-O3 -march=corei7 -mtune=corei7”
[13] “”
[14] “CXX14FLAGS=-O3 -march=corei7 -mtune=corei7”
[15] “CXX14 = (BINPREF)g++ -m(WIN) -std=c++1y”
[16] “CXX11FLAGS=-O3 -march=corei7 -mtune=corei7”
[17] “”
[18] “CXX14FLAGS=-O3 -march=corei7 -mtune=corei7”
[19] “CXX14 = (BINPREF)g++ -m(WIN) -std=c++1y”
[20] “CXX11FLAGS=-O3 -march=corei7 -mtune=corei7”
[21] “”
[22] “CXX14FLAGS=-O3 -march=corei7 -mtune=corei7”
[23] “CXX14 = (BINPREF)g++ -m(WIN) -std=c++1y”
[24] “CXX11FLAGS=-O3 -march=corei7 -mtune=corei7”
[25] “”
[26] “CXX14FLAGS=-O3 -march=corei7 -mtune=corei7”
[27] “CXX14 = (BINPREF)g++ -m(WIN) -std=c++1y”
[28] “CXX11FLAGS=-O3 -march=corei7 -mtune=corei7”
[29] “”
[30] “CXX14FLAGS=-O3 -march=corei7 -mtune=corei7”
[31] “CXX14 = (BINPREF)g++ -m(WIN) -std=c++1y”
[32] “CXX11FLAGS=-O3 -march=corei7 -mtune=corei7”
[33] “”
[34] “CXX14FLAGS=-O3 -march=corei7 -mtune=corei7”
[35] “CXX14 = (BINPREF)g++ -m(WIN) -std=c++1y”
[36] “CXX11FLAGS=-O3 -march=corei7 -mtune=corei7”
[37] “”
[38] “CXX14FLAGS=-O3 -march=corei7 -mtune=corei7”
[39] “CXX14 = (BINPREF)g++ -m(WIN) -std=c++1y”
[40] “CXX11FLAGS=-O3 -march=corei7 -mtune=corei7”
[41] “”
[42] “CXX14FLAGS=-O3 -march=corei7 -mtune=corei7”
[43] “CXX14 = (BINPREF)g++ -m(WIN) -std=c++1y”
[44] “CXX11FLAGS=-O3 -march=corei7 -mtune=corei7”
[45] “”
[46] “CXX14FLAGS=-O3 -march=corei7 -mtune=corei7”
[47] “CXX14 = (BINPREF)g++ -m(WIN) -std=c++1y”
[48] “CXX11FLAGS=-O3 -march=corei7 -mtune=corei7”
[49] “”
[50] “CXX14FLAGS=-O3 -march=corei7 -mtune=corei7”
[51] “CXX14 = (BINPREF)g++ -m(WIN) -std=c++1y”
[52] “CXX11FLAGS=-O3 -march=corei7 -mtune=corei7”
[53] “”
[54] “CXX14FLAGS=-O3 -march=corei7 -mtune=corei7”
[55] “CXX14 = (BINPREF)g++ -m(WIN) -std=c++1y”
[56] “CXX11FLAGS=-O3 -march=corei7 -mtune=corei7”
[57] “”
[58] “CXX14FLAGS=-O3 -march=corei7 -mtune=corei7”
[59] “CXX14 = (BINPREF)g++ -m(WIN) -std=c++1y”
[60] “CXX11FLAGS=-O3 -march=corei7 -mtune=corei7”
readLines(“~/.Rprofile”)
[1] “Sys.setenv(BINPREF = "C:\Users\R-3.4.3\rtools40/usr/mingw_(WIN)/bin/\")" readLines("~/.Renviron") [1] "PATH=\"C:\\Users\\R-3.4.3\\rtools40/usr/bin;{PATH}"”

There are a few things here. First, you’ll need to reset your Makevars file, because you have multiple CXX14FLAGS statements.

Can you run:

writeLines("CXX14FLAGS += -mtune=native -O3 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2",
           con = "~/.R/Makevars.win")

Then you’ll need to downgrade your withr package (for a different issue):

devtools::install_version("withr", version="2.2.0")

Then, can you follow the RStan Getting Started guide sections on installing on R4.0: https://github.com/stan-dev/rstan/wiki/Installing-RStan-from-source-on-Windows#r40

Once you’ve done that, can you test your installation with:

library(rstan)
example(stan_model,run.dontrun=T)

I couldn’t downgrade the withr package. Here is the error I got when I tried to run your
devtools::install_version(“withr”, version=“2.2.0”).

Error: Failed to install ‘unknown package’ from URL:
(converted from warning) installation of package ‘C:/Users/AppData/Local/Temp/RtmpULC9oW/remotes5a8c6978aac/withr’ had non-zero exit status

Odd, how about:

install.packages("https://cran.r-project.org/src/contrib/Archive/withr/withr_2.2.0.tar.gz",
                 type="source",repos=NULL)

I tried with no luck. I don’t know where the problem is coming from.

install.packages(“https://cran.r-project.org/src/contrib/Archive/withr/withr_2.2.0.tar.gz”,

  •              type="source",repos=NULL)
    

Installing package into ‘\server/userhome/students4/My Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
trying URL ‘https://cran.r-project.org/src/contrib/Archive/withr/withr_2.2.0.tar.gz
Content type ‘application/x-gzip’ length 99545 bytes (97 KB)
downloaded 97 KB

Error: ‘\U’ used without hex digits in character string starting "“C:\U”
Execution halted
Warning in install.packages :
installation of package ‘C:/Users/AppData/Local/Temp/RtmpSAFfWb/downloaded_packages/withr_2.2.0.tar.gz’ had non-zero exit status

Ah that’s a very helpful error message. This is because of how you’ve configured RTools, I suspect that you can’t install any packages from source.

Can I just check that RTools4 is installed in: C:\Users\R-3.4.3\rtools40? If so, is there a reason it was installed there instead of the default?

Because I don’t have access to the default location on the computer due to admin right restrictions. So I saved it in a folder I believe that R can access, and set it in the Path. I need to be on the network to be able to work in that manner but due to working from home I can’t access it. So if I can’t install packages from source, what would be another option?

It’s an easy fix, just had to make sure you meant to install it there. The issue is that your BINPREF statement is using backslashes for the directory, you just need to change these to forward-slashes. You can do this from R via:

path = "C:/Users/R-3.4.3/rtools40/mingw$(WIN)/bin/"
writeLines(paste0('Sys.setenv(BINPREF = "',path,'")'), con = "~/.Rprofile")

Then restart R and try that withr install again

I tried that and I was able to install withr package finally. Now I tried installing rstan from the source as per the instructions in the link you gave me. But no luck again :(
Here is the error messege I got. Its getting late here, so I will be able to follow up again in about 10-12 hours. Thank you, and talk to you tomorrow my time!

remotes::install_github(“stan-dev/rstan”, ref = “develop”, subdir = “rstan/rstan”, build_opts = “”)
Downloading GitHub repo stan-dev/rstan@develop
stan-dev-rstan-f133b14/StanHeaders/inst/include/libsundials: Can’t create ‘\\?\C:\Users\AppData\Local\Temp\Rtmp2rIAAt\remotes4e8c6a1d4920\stan-dev-rstan-f133b14\StanHeaders\inst\include\libsundials’
stan-dev-rstan-f133b14/StanHeaders/inst/include/src: Can’t create ‘\\?\C:\Users\AppData\Local\Temp\Rtmp2rIAAt\remotes4e8c6a1d4920\stan-dev-rstan-f133b14\StanHeaders\inst\include\src’
stan-dev-rstan-f133b14/StanHeaders/inst/include/stan: Can’t create ‘\\?\C:\Users\AppData\Local\Temp\Rtmp2rIAAt\remotes4e8c6a1d4920\stan-dev-rstan-f133b14\StanHeaders\inst\include\stan’
tar.exe: Error exit delayed from previous errors.
Error: Failed to install ‘rstan’ from GitHub:
Git does not seem to be installed on your system.
In addition: Warning message:
In utils::untar(tarfile, …) :
‘tar.exe -xf “C:\Users\AppData\Local\Temp\Rtmp2rIAAt\file4e8c53a05fb6.tar.gz” -C “C:/Users/AppData/Local/Temp/Rtmp2rIAAt/remotes4e8c6a1d4920”’ returned error code 1
devtools::install_github(“stan-dev/rstan”, ref = “develop”, subdir = “rstan/rstan”, build_opts = “”)
Downloading GitHub repo stan-dev/rstan@develop
stan-dev-rstan-f133b14/StanHeaders/inst/include/libsundials: Can’t create ‘\\?\C:\Users\AppData\Local\Temp\Rtmp2rIAAt\remotes4e8c1a9137e4\stan-dev-rstan-f133b14\StanHeaders\inst\include\libsundials’
stan-dev-rstan-f133b14/StanHeaders/inst/include/src: Can’t create ‘\\?\C:\Users\AppData\Local\Temp\Rtmp2rIAAt\remotes4e8c1a9137e4\stan-dev-rstan-f133b14\StanHeaders\inst\include\src’
stan-dev-rstan-f133b14/StanHeaders/inst/include/stan: Can’t create ‘\\?\C:\Users\AppData\Local\Temp\Rtmp2rIAAt\remotes4e8c1a9137e4\stan-dev-rstan-f133b14\StanHeaders\inst\include\stan’
tar.exe: Error exit delayed from previous errors.
Error: Failed to install ‘rstan’ from GitHub:
Git does not seem to be installed on your system.
In addition: Warning message:
In utils::untar(tarfile, …) :
‘tar.exe -xf “C:\Users\AppData\Local\Temp\Rtmp2rIAAt\file4e8c6fb01cef.tar.gz” -C “C:/Users/AppData/Local/Temp/Rtmp2rIAAt/remotes4e8c1a9137e4”’ returned error code 1
install.packages(“rstan”, type = “source”)
Installing package into ‘C:/Users/R/R-4.0.3/library’
(as ‘lib’ is unspecified)
trying URL ‘http://cran.rstudio.com/src/contrib/rstan_2.21.2.tar.gz
Content type ‘application/x-gzip’ length 1152008 bytes (1.1 MB)
downloaded 1.1 MB

  • installing source package ‘rstan’ …
    ** package ‘rstan’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs

*** arch - i386
C:/Users/R-3.4.3/rtools40mingw32/bin/g++ -std=gnu++14 -I"C:/Users/R/R-40~1.3/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I’\server/userhome/students4/My Documents/R/win-library/4.0/Rcpp/include’ -I’\server/userhome/students4/My Documents/R/win-library/4.0/RcppEigen/include’ -I’\server/userhome/students4/My Documents/R/win-library/4.0/BH/include’ -I’\server/userhome/students4/My Documents/R/win-library/4.0/StanHeaders/include’ -I’\server/userhome/students4/My Documents/R/win-library/4.0/RcppParallel/include’ -DRCPP_PARALLEL_USE_TBB=1 -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -mtune=native -O3 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -c sparse_extractors.cpp -o sparse_extractors.o
sh: C:/Users/R-3.4.3/rtools40mingw32/bin/g++: No such file or directory
make: *** [C:/Users/R/R-40~1.3/etc/i386/Makeconf:229: sparse_extractors.o] Error 127
ERROR: compilation failed for package ‘rstan’

  • removing ‘C:/Users/R/R-4.0.3/library/rstan’
    Warning in install.packages :
    installation of package ‘rstan’ had non-zero exit status

Hmm, what do you get from:

readLines("~/.Rprofile")

Hello there, here is what I got.
“Sys.setenv(BINPREF = "C:/Users/R-3.4.3/rtools40mingw$(WIN)/bin/")”