no problem, I can proceed with a warning message :)
The warning message:
Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
'C:/rtools40/usr/mingw_/bin/g++' not found
Is caused by the get_CXX
function in misc.R
:
get_CXX <- function(CXX14 = TRUE) {
if (.Platform$OS.type != "windows")
return (system2(file.path(R.home(component = "bin"), "R"),
args = paste("CMD config", ifelse(CXX14, "CXX14", "CXX11")),
stdout = TRUE, stderr = FALSE))
ls_path <- Sys.which("ls")
if (ls_path == "")
return(NULL)
install_path <- dirname(dirname(ls_path))
file.path(install_path,
paste0('mingw_', Sys.getenv('WIN')), 'bin', 'g++')
}
Since Rtools4, there’s no underscore in the mingw
path, and Sys.getenv("WIN")
is now returning ""
(for me at least).
Hi @bbbales2. Thanks for your help.
I did uninstall and install again Rtools40 and rstan and now it it works. However I am getting the same warning as @spinkney.
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
'C:/rtools40/usr/mingw_/bin/g++' not found
The model works so I can work with the warning
Thanks everyone for the time and effort.
Similarly, is it possible to also get the -include path/to/Eigen.hpp
with quotations around the include? (i.e. -include "path/to/Eigen.hpp"
), since that’s causing issues too
Don’t worry about the
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
‘C:/rtools40/usr/mingw_/bin/g++’ not found
Some of the other things should be fixed by the imminent StanHeaders. Others may need to be fixed in the inline package.
By “don’t worry” do you mean it is (or will be) fixed or just that it can be ignored?
Both
Maybe the solution is given somewhere on this thread, but it is just too long and confusing.
I have just reinstalled rstan and tried to run the schools example in https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started
When I run fit <- stan(file = 'schools.stan', data = schools_dat)
, I get this error:
“Error in file(con, “r”) : cannot open the connection
In addition: Warning messages:
1: In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
‘C:/rtools40/usr/mingw_/bin/g++’ not found
2: In system(cmd, intern = !verbose) :
running command ‘C:/PROGRA~1/R/R-40~1.2/bin/x64/R CMD SHLIB file2968734e19d4.cpp 2> file2968734e19d4.cpp.err.txt’ had status 1
3: In file(con, “r”) :
cannot open file ‘file2968734e19d4.cpp.err.txt’: No such file or directory
Error in sink(type = “output”) : invalid connection”
Any pointer?
I thought that running file.edit("~/.R/Makevars.win")
and file.edit("~/.R/Makevars")
was not needed anymore. Should I try?
sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)
Matrix products: default
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rstan_2.21.2 ggplot2_3.3.2 StanHeaders_2.21.0-5
loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 pillar_1.4.6 compiler_4.0.2 prettyunits_1.1.1
[5] tools_4.0.2 pkgbuild_1.1.0 jsonlite_1.7.0 lifecycle_0.2.0
[9] tibble_3.0.3 gtable_0.3.0 pkgconfig_2.0.3 rlang_0.4.7
[13] cli_2.0.2 rstudioapi_0.11 parallel_4.0.2 curl_4.3
[17] xfun_0.16 loo_2.3.1 gridExtra_2.3 withr_2.2.0
[21] dplyr_1.0.1 generics_0.0.2 vctrs_0.3.2 stats4_4.0.2
[25] grid_4.0.2 tidyselect_1.1.0 glue_1.4.1 inline_0.3.15
[29] R6_2.4.1 processx_3.4.3 fansi_0.4.1 purrr_0.3.4
[33] callr_3.4.3 magrittr_1.5 codetools_0.2-16 matrixStats_0.56.0
[37] scales_1.1.1 ps_1.3.3 ellipsis_0.3.1 assertthat_0.2.1
[41] colorspace_1.4-1 V8_3.2.0 tinytex_0.25 RcppParallel_5.0.2
[45] munsell_0.5.0 crayon_1.3.4
I am running R via RStudio Version 1.3.1073
Hi,
try running
remotes::install_github("bgoodri/inline")
and try again.
Now I get that:
fit <- stan(file = 'schools.stan', data = schools_dat)
make cmd is
make -f “C:/PROGRA~1/R/R-40~1.2/etc/x64/Makeconf” -f “C:/PROGRA~1/R/R-40~1.2/share/make/winshlib.mk” CXX=‘(CXX14) (CXX14STD)’ CXXFLAGS=‘(CXX14FLAGS)' CXXPICFLAGS='(CXX14PICFLAGS)’ SHLIB_LDFLAGS=‘(SHLIB_CXX14LDFLAGS)' SHLIB_LD='(SHLIB_CXX14LD)’ SHLIB=“file4383f1b50e6.dll” WIN=64 TCLBIN=64 OBJECTS=“file4383f1b50e6.o”
make would use
“C:/rtools40/mingw64/bin/“g++ -std=gnu++14 -I"C:/PROGRA~1/R/R-40~1.2/include” -DNDEBUG -I"C:/Program Files/R/R-4.0.2/library/Rcpp/include/” -I"C:/Program Files/R/R-4.0.2/library/RcppEigen/include/" -I"C:/Program Files/R/R-4.0.2/library/RcppEigen/include/unsupported" -I"C:/Program Files/R/R-4.0.2/library/BH/include" -I"C:/Program Files/R/R-4.0.2/library/StanHeaders/include/src/" -I"C:/Program Files/R/R-4.0.2/library/StanHeaders/include/" -I"C:/Program Files/R/R-4.0.2/library/RcppParallel/include/" -I"C:/Program Files/R/R-4.0.2/library/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DBOOST_NO_AUTO_PTR -include “C:/Program Files/R/R-4.0.2/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp” -std=c++1y -include C:/Program Files/R/R-4.0.2/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp -I “C:/Program Files/R/R-4.0.2/library/StanHeaders/include” -I “C:/Program Files/R/R-4.0.2/library/RcppEigen/include” -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c file4383f1b50e6.cpp -o file4383f1b50e6.o
if test “zfile4383f1b50e6.o” != “z”; then
if test -e “file4383f1b50e6-win.def”; then
echo “C:/rtools40/mingw64/bin/“g++ -shared -s -static-libgcc -o file4383f1b50e6.dll file4383f1b50e6-win.def file4383f1b50e6.o “C:/Program Files/R/R-4.0.2/library/rstan/lib/x64/libStanServices.a” -L"C:/Program Files/R/R-4.0.2/library/StanHeaders/libs/x64” -lStanHeaders -L"C:/Program Files/R/R-4.0.2/library/RcppParallel/lib/x64” -ltbb -L"C:/PROGRA~1/R/R-40~1.2/bin/x64" -lR ;
“C:/rtools40/mingw64/bin/“g++ -shared -s -static-libgcc -o file4383f1b50e6.dll file4383f1b50e6-win.def file4383f1b50e6.o “C:/Program Files/R/R-4.0.2/library/rstan/lib/x64/libStanServices.a” -L"C:/Program Files/R/R-4.0.2/library/StanHeaders/libs/x64” -lStanHeaders -L"C:/Program Files/R/R-4.0.2/library/RcppParallel/lib/x64” -ltbb -L"C:/PROGRA~1/R/R-40~1.2/bin/x64" -lR ;
else
echo EXPORTS > tmp.def;
“C:/rtools40/mingw64/bin/“nm file4383f1b50e6.o | sed -n ‘s/^.* [BCDRT] / /p’ | sed -e ‘/[.]refptr[.]/d’ -e ‘/[.]weak[.]/d’ | sed 's/[^ ][^ ]*/”&”/g’ >> tmp.def;
echo “C:/rtools40/mingw64/bin/“g++ -shared -s -static-libgcc -o file4383f1b50e6.dll tmp.def file4383f1b50e6.o “C:/Program Files/R/R-4.0.2/library/rstan/lib/x64/libStanServices.a” -L"C:/Program Files/R/R-4.0.2/library/StanHeaders/libs/x64” -lStanHeaders -L"C:/Program Files/R/R-4.0.2/library/RcppParallel/lib/x64” -ltbb -L"C:/PROGRA~1/R/R-40~1.2/bin/x64" -lR ;
“C:/rtools40/mingw64/bin/“g++ -shared -s -static-libgcc -o file4383f1b50e6.dll tmp.def file4383f1b50e6.o “C:/Program Files/R/R-4.0.2/library/rstan/lib/x64/libStanServices.a” -L"C:/Program Files/R/R-4.0.2/library/StanHeaders/libs/x64” -lStanHeaders -L"C:/Program Files/R/R-4.0.2/library/RcppParallel/lib/x64” -ltbb -L"C:/PROGRA~1/R/R-40~1.2/bin/x64" -lR ;
rm -f tmp.def;
fi
fi
Error in compileCode(f, code, language = language, verbose = verbose) :
g++.exe: error: Files/R/R-4.0.2/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directorymake: *** [C:/PROGRA~1/R/R-40~1.2/etc/x64/Makeconf:229: file4383f1b50e6.o] Error 1
In addition: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
‘C:/rtools40/usr/mingw_/bin/g++’ not found
Error in sink(type = “output”) : invalid connection
The error messages are formatted; how can I stop this automatic formatting so that you can see the true error messages?
There is currently a problem if the R library is located in a path with spaces. In your case you have it in “C:/Program Files”…
So you will need to set an alternative location. If you need guidance on that see https://stackoverflow.com/questions/31707941/how-do-i-change-the-default-library-path-for-r-packages
https://stackoverflow.com/questions/2698269/how-do-you-change-library-location-in-r
Is that error due to R? There is no possibility to fix it in our end?
(Windows has “short” path for everyfile, which are always path-free; cmdstanpy uses it)
There is definitely a way of fixing it, but before the fix reaches CRAN, this is the workaround.
I will try to install packages in the user folder (in C:/Users/…). But I have taken the habit to install all packages as admin because there were sometimes weird issues with installing/running some packages (e.g. renv, rrtools).
I will be waiting for the fix then!!
I’ve reinstalled all packages in my user library (C:/Users/…/Documents/R/win-library/4.0).
I get no error anymore, even without running remotes::install_github("bgoodri/inline")
.
But I do get a warning:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
‘C:/rtools40/usr/mingw_/bin/g++’ not found
rtools40 is installed of course:
Sys.which("make")
make
“C:\rtools40\usr\bin\make.exe”
Should I still install inline
?
In that case you do not need to install. You can ignore that warning. Everything should work, the warning will go away in the next release.
For anyone else encountering this topic, go to Workarounds for current Rstan Windows issues
for a summary of known issues with workarounds and advices.
Thank you for your help. And thanks for the overview of the workarounds!
Hopefully Rstan will be running smoothly on Windows very soon.
Thank you for the Workaround article, I just encountered another strange behavior using Windows with R (4.0.2); when I run my script for the first time R will report:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
‘-E’ not found
If I run the same script for the second time R will crash.
Can you post the entire output for
example(stan_model, package = “rstan”, run.dontrun = TRUE)