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?
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?
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’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”
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.