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

Alright, let’s try moving the entire package installation directory to your local drive (i.e., all R packages will get installed to a folder on your computer, rather than the network drive).

First we need to remove those RStan and StanHeaders packages:

remove.packages(c("rstan","StanHeaders"))

And restart R.

Given that we know you have permissions to the C:/Users/R folder, we’ll create a folder there which your packages will be installed into:

dir.create("C:/Users/R/win-library/4.0", recursive = T)

Next, we need to tell R to install and load R packages from this directory. We can do this by setting the R_LIBS_USER environment variable using your .Renviron file:

cat("R_LIBS_USER = \"C:/Users/R/win-library/4.0\"",
    file="~/.Renviron", append=TRUE)

And then restart R. If you look at the ‘Packages’ pane in RStudio, you should only see packages listed under ‘System Library’. Next, we’ll copy R packages from your old directory to this new one (otherwise you’ll have to re-install them all):

file.copy(from="~/R/win-library/4.0/",to="C:/Users/R/win-library/",recursive = T)

Depending on how many packages you have installed, this could take a few minutes. Then restart R again.

If all of the above ran without any errors (fingers crossed), then try to install RStan and run the example model again:

install.packages("rstan")
library(rstan)
example(stan_model, run.dontrun=T)
4 Likes