Yes. Install happened without errors. What shall I do now?
Can you try the example model from above again?
Sadly I got the following error.
Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) :
cc1plus.exe: fatal error: \server/userhome/students4/My Documents/R/win-library/4.0/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directorycompilation terminated.make: *** [C:/Users/R/R-40~1.3/etc/x64/Makeconf:229: file5ea43a8f64e0.o] Error 1
In addition: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
‘C:/Users/R-34~1.3/rtools40/usr/mingw_/bin/g++’ not found
Do you think there is a reason why it can’t locate “C:/Users/R-34~1.3/rtools40/usr/mingw_/bin/g++’ not found” ??
Unfortunately its getting late here for me. So I might retire since its late here. I shall be able to reply again tomorrow morning.
Yes, but don’t worry about it.
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)
Thanks Andrjohns. I did all the steps, and after I ran the model
I got this
Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
‘C:/Users/R-34~1.3/rtools40/usr/mingw_/bin/g++’ not found
That warning is completely safe to ignore, it will be fixed in the next release. Did everything run and finish sampling?
Yes! I am super thankful!!! You have been such a great help on this, I sincerely appreciate it!!!
Fantastic news! Thanks for hanging in there with the debugging, and sorry that it’s been such a journey.
Not at all, actually this has been the quickest debugging I have ever had! So I am super thankful, and you gave me insights on the problem which I had no idea about.
Glad it’s working now @ASaeed!
And seriously thanks to you @andrjohns for hanging in there and helping them get everything sorted out. That was quite the debugging journey!
Dear Mr. Johns
I am currently facing the same issue as ASaeed faced half a years ago. However, when I try the following code suggested by you, I get this warning:
system(“touch foo.cpp”)
[1] 127
system(“R CMD SHLIB foo.cpp”)
Warning:
In system(cmd) : ‘make’ not found
[1] 1
So I guess that the C++ compiler is not working properly. Could you tell me how I can fix this?
Many thanks in advance! :)
Kind regards, damajo
Sorry for the delay. Yes, this indicates that R can’t find your RTools installation. Can you post the output from:
Sys.getenv("PATH")
Sys.getenv("BINPREF")
readLines("~/.Renviron")
readLines(".~/.Rprofile")
pkgbuild::check_rtools(debug = TRUE)
That will give me a better idea of where the issue could be
No worries! I am certainly glad to receive some help since I tried many proposed solutions from the stanforum without any success. Here is the output:
Sys.getenv(“PATH”)
[1] “C:\Program Files\R-4.0.5\bin\x64;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Windows\System32\OpenSSH;C:\Users\David\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Android;C:\Windows\System32;C:\Program Files\PuTTY;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\Binn;C:\Program Files\Microsoft SQL Server\150\Tools\Binn;C:\Program Files\Microsoft SQL Server\150\DTS\Binn;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn;C:\Program Files\Azure Data Studio\bin;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn;C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files\Git\cmd;C:\miketex\miktex\bin\x64;C:\Users\David\AppData\Roaming\TinyTeX\bin\win32;C:\Users\David\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64;C:\Users\David\AppData\Local\GitHubDesktop\bin;C:\Users\David\AppData\Local\Programs\Python\Python39;C:\Users\David\AppData\Local\Programs\Python\Python39\Scripts;C:\Users\David\AppData\Local\GitHubDesktop\bin”
Sys.getenv(“BINPREF”)
[1] “”
readLines("~/.Renviron")
Error in file(con, “r”) : cannot open connection
Additional: Warning message:
In file(con, “r”) :
cannot open file ‘C:/Users/David/OneDrive - ZHAW/Documents/.Renviron’: No such file or directory
readLines(".~/.Rprofile")
Error in file(con, “r”) : cannot open connection.
Additional: Warning message:
In file(con, “r”) :
cannot open file ‘.~/.Rprofile’: No such file or directory
pkgbuild::check_rtools(debug = TRUE)
Found in Rtools 4.0 installation folder
[1] TRUE
There seems to be a missing connection.
It looks like the configuration for RTools4 is missing, can you try the R4.0 instructions on the RStan Getting Started page: Configuring C Toolchain for Windows · stan-dev/rstan Wiki · GitHub
I did and this is now the output:
Sys.getenv(“PATH”)
[1] “C:\rtools40\usr\bin;C:\Program Files\R-4.0.5\bin\x64;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\System32\OpenSSH\;C:\Users\David\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Android;C:\Windows\System32;C:\Program Files\PuTTY\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files\Azure Data Studio\bin;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files\Git\cmd;C:\miketex\miktex\bin\x64\;C:\Users\David\AppData\Roaming\TinyTeX\bin\win32;C:\Users\David\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64\;C:\Users\David\AppData\Local\GitHubDesktop\bin;C:\Users\David\AppData\Local\Programs\Python\Python39;C:\Users\David\AppData\Local\Programs\Python\Python39\Scripts;C:\Users\David\AppData\Local\GitHubDesktop\bin”
Sys.getenv(“BINPREF”)
[1] “”
readLines("~/.Renviron")
[1] “PATH=”{RTOOLS40_HOME}\\usr\\bin;{PATH}""
readLines(".~/.Rprofile")
Error in file(con, “r”) : cannot open connection.
Additional: Warning message:
In file(con, “r”) :
cannot open file ‘.~/.Rprofile’: No such file or directory
pkgbuild::check_rtools(debug = TRUE)
Found in Rtools 4.0 installation folder
[1] TRUE
And what do you get from:
example(stan_model,package="rstan",run.dontrun=T)
Error in inDL(x, as.logical(local), as.logical(now), …) :
cannot load shared object ‘C:/Users/David/AppData/Local/Temp/RtmpgFkOt4/file43e07d3c3216.dll’:
LoadLibrary failure: A DLL initialisation routine has failed.
Additional: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
‘C:/rtools40/usr/mingw_/bin/g++’ not found
Try restarting R (making sure that rstan
doesn’t get loaded) and reinstalling from source:
# Compile packages using all cores
Sys.setenv(MAKEFLAGS = paste0("-j",parallel::detectCores()))
remove.packages(c("StanHeaders","rstan"))
install.packages(c("StanHeaders","rstan"),type="source")