Rstan re-install error after new Rstudio crashes

Dear everyone,

I’m running Windows 10 RStudio 1.4.1103 and R 4.0.3.

A previously-working relatively simple mixed effects model was working, but started crashing RStudio after a long compile.

I tried to re-install rstan and StanHeaders from source to address this error, but now run into the following error (StanHeaders installs okay).

g++.exe: error: Global: No such file or directory
g++.exe: error: .Rprofile: No such file or directory
g++.exe: error: loaded!: No such file or directory
make: *** [C:/PROGRA~1/R/R-4.0.3/etc/i386/Makeconf:229: sparse_extractors.o] Error 1
ERROR: compilation failed for package ‘rstan’

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

Any help with this much appreciated!!

Best,
David

Are you able to install other packages from source? What happens when you run:

Install.packages("jsonlite",type ="source")

Hi Andrew,

Yes jsonlite installs fine. My error arises from trying to install rstan from source, but StanHeaders also seems to install from source okay. I saw your answers to similar questions as mine from a web search as well on this forum, but unfortunately those solutions didn’t seem to work for me. THank you !

David

The first thing to test is whether you’re able to compile any c++. What output do you get from:

system("touch foo.cpp")
system("R CMD SHLIB foo.cpp")

system(“touch foo.cpp”)
[1] 0

system(“R CMD SHLIB foo.cpp”)

"C:/RBuildTools/4.0/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-4.0.3/include" -DNDEBUG          -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c foo.cpp -o foo.o
C:/RBuildTools/4.0/mingw64/bin/g++ -std=gnu++11 -shared -s -static-libgcc -o foo.dll tmp.def foo.o -LC:/PROGRA~1/R/R-4.0.3/bin/x64 -lR
[1] 0

Hmm very odd, everything seems like it should be working. Can you try restarting R, making sure that it doesn’t a previous workspace or any packages (as clean a session as possible) and then try the rstan source install again:

install.packages("rstan",type="source")

And copy as much of the output here as you can? Hopefully there’s an earlier error that might give me a clue

install.packages(“rstan”,type=“source”)
Installing package into ‘C:/Users/davidch/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
trying URL ‘https://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

Global .Rprofile loaded!

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

*** arch - i386
“C:/RBuildTools/4.0/mingw32/bin/“g++ -std=gnu++14 -I"C:/PROGRA~1/R/R-4.0.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 Global .Rprofile loaded! -DRCPP_PARALLEL_USE_TBB=1 -I’C:/Users/davidch/Documents/R/win-library/4.0/Rcpp/include’ -I’C:/Users/davidch/Documents/R/win-library/4.0/RcppEigen/include’ -I’C:/Users/davidch/Documents/R/win-library/4.0/BH/include’ -I’C:/Users/davidch/Documents/R/win-library/4.0/StanHeaders/include’ -I’C:/Users/davidch/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
g++.exe: error: Global: No such file or directory
g++.exe: error: .Rprofile: No such file or directory
g++.exe: error: loaded!: No such file or directory
make: *** [C:/PROGRA~1/R/R-4.0.3/etc/i386/Makeconf:229: sparse_extractors.o] Error 1
ERROR: compilation failed for package ‘rstan’

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

That’s the full output.

I think the crashing may have started after I cancelled a model compilation by pressing the STOP button in RStudio, would there be any possibility that something messed up by doing that?

The error is caused by the bolded section:

“C:/RBuildTools/4.0/mingw32/bin/“g++ -std=gnu++14 -I"C:/PROGRA~1/R/R-4.0.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 Global .Rprofile loaded! -DRCPP_PARALLEL_USE_TBB=1 -I’C:/Users/davidch/Documents/R/win-library/4.0/Rcpp/include’ -I’C:/Users/davidch/Documents/R/win-library/4.0/RcppEigen/include’ -I’C:/Users/davidch/Documents/R/win-library/4.0/BH/include’ -I’C:/Users/davidch/Documents/R/win-library/4.0/StanHeaders/include’ -I’C:/Users/davidch/Documents/R/win-library/4.0/RcppParallel/include’

For some reason R is interspersing that loading message with the compilation arguments, and it causes g++ to fail. Have you changed any settings recently around your .Rprofile handling or other RStudio settings?

This is the first time that I’ve seen this

Wow strange. My .Rprofile has some custom institutional settings and is pasted below (i’ve removed the links and passwords ;+) )
Perhaps that first line with cat() is what is causing this? I delete it and try again now.


cat("Global .Rprofile loaded!\n\n")

# OTHER SETTINGS

Yep that cat statement looks like a likely culprit

(deleted)

successfully installed! I try a model run now.

OK great! Everything went through. Thanks very much Andrew for the help! funny error thanks for picking up on it up so quickly.

All the best!
David

1 Like