Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in compileCode (Error 127) When running rstan program

Tags:

r

rtools

rstan

I am trying to install Rstan. I have no problem installing the package and running it. However, when I try running a program that uses the library I get the following error:

    Error in compileCode(f, code, language = language, verbose = verbose) : 
sh: line 1: K:/Software/rtools40/ucrt64/mingw_64/bin/g++: 
No such file or directorymake: *** [K:/Software/R-41~1.2/etc/x64/Makeconf:245: file9706b781d3e.o] Error 127
Error in sink(type = "output") : invalid connection

I have spent some time trying to trouble shoot it but I simply cannot solve it. I have checked that rtools is in the path using:

writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")

When I went directly into the directorymake referenced by the error [K:/Software/R-41~1.2/etc/x64/Makeconf:245: file9706b781d3e.o] it is there! But the K:/Software/rtools40/ucrt64/mingw_64/bin/g++ is not. Specifically the ~/mingw_64/bin/g++.
Does anyone has had this issue?
How can I point rstan to a different directory or restore the default one? (Note: I have uninstall it and install it using the headers and without headers and updated rtools and R

like image 797
EduardoRod Avatar asked Apr 29 '26 13:04

EduardoRod


1 Answers

Answer: Needed to configure the C++ Tool Chain as per this guide: https://github.com/stan-dev/rstan/wiki/Configuring-C---Toolchain-for-Windows . I had issues with this as well but everything got resolved when I deleted the .Rprofile file int he documents folder.

After configuring the C++ tool I put Rtools in the path again and it worked seamlessly!

like image 74
EduardoRod Avatar answered May 01 '26 03:05

EduardoRod



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!