Toolchain not working in Win10

Hi,

I’m trying to install rstan in R(3.5.3)/Rstudio (1.1.463 )/Windows 10. I installed Rtools35 according to instructions.

When I run

pkgbuild::has_build_tools(debug = TRUE)

it returns

TRUE

like it should.

My C:\\Users\user\documents\.R\makevars.win file contains:

CXX14FLAGS=-O3 -march=native -mtune=native
CXX11FLAGS=-O3 -march=native -mtune=native

However when I try to compile a .stan file it throws an error like this

fit <- stan(file = '8schools.stan', data = schools_dat)

Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! In file included from C:/Users/user/Documents/R/win-library/3.5/BH/include/boost/random/detail/integer_log2.hpp:19:0,
                 from C:/Users/user/Documents/R/win-library/3.5/BH/include/boost/random/detail/int_float_pair.hpp:26,
                 from C:/Users/user/Documents/R/win-library/3.5/BH/include/boost/random/exponential_distribution.hpp:27,
                 from C:/Users/user/Documents/R/win-library/3.5/BH/include/boost/random/gamma_distribution.hpp:25,
                 from C:/Users/user/Documents/R/win-library/3.5/StanHeaders/include/stan/math/prim/mat/prob/dirichlet_rng.hpp:5,
                 from C:/Users/user/Documents/R/win-library/3.5/StanHeaders/include/stan/math/prim/mat.hpp:276,
                 from C:/Users/user/Documents/R/win-library/3.5/StanHeaders/include/stan/math/rev/mat.hpp:12,
                 from C:/Users/user/Documents/R/win-libra
In addition: Warning message:
In system(cmd, intern = !verbose) :
  running command 'C:/PROGRA~1/R/R-35~1.3/bin/x64/R CMD SHLIB file19ac68277a72.cpp 2> file19ac68277a72.cpp.err.txt' had status 1
Error in sink(type = "output") : invalid connection

EDIT: traceback() gives

4: sink(type = "output")
3: cxxfunctionplus(signature(), body = paste(" return Rcpp::wrap(\"", 
       model_name, "\");", sep = ""), includes = inc, plugin = "rstan", 
       save_dso = save_dso | auto_write, module_name = paste("stan_fit4", 
           model_cppname, "_mod", sep = ""), verbose = verbose)
2: stan_model(file, model_name = model_name, model_code = model_code, 
       stanc_ret = NULL, boost_lib = boost_lib, eigen_lib = eigen_lib, 
       save_dso = save_dso, verbose = verbose)
1: stan(file = "8schools.stan", data = schools_dat)

Or if I run

fx <- inline::cxxfunction( signature(x = "integer", y = "numeric" ) , 'return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;' )

Warning message:
In system(cmd) : 'make' not found

ERROR(s) during compilation: source code errors or compiler configuration errors!

Program source:
  1: 
  2: // includes from the plugin
  3: #include <R.h>
  4: #include <Rdefines.h>
  5: #include <R_ext/Error.h>
  6: 
  7: 
  8: // user includes
  9: 
 10: 
 11: // declarations
 12: extern "C" {
 13: SEXP file19ac31804fd9( SEXP x, SEXP y) ;
 14: }
 15: 
 16: // definition
 17: 
 18: SEXP file19ac31804fd9( SEXP x, SEXP y ){
 19: return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ; 
 20: Rf_warning("your C++ program does not return anything"); 
 21:  return R_NilValue ; 
 22: }
 23: 
 24: 
Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! Warning message:
In system(cmd) : 'make' not found
In addition: Warning message:
In system(cmd, intern = !verbose) :
  running command 'C:/PROGRA~1/R/R-35~1.3/bin/x64/R CMD SHLIB file19ac31804fd9.cpp 2> file19ac31804fd9.cpp.err.txt' had status 1

Could someone help me out please?

Thanks,

S

Try it like

fit <- stan(file = '8schools.stan', data = schools_dat, verbose = TRUE)

and then tell us the part of the error message that has the string error: in it.

Thanks for looking into it!

Somehow I managed to make it work by installing rstan and its dependencies in the System Library (Program Files/R/R-3.5.3/library) rather than in the User Library (C:\Users\user-name\Documents\R\win-library\3.5).

My knowledge is not sufficient to explain why this works or why installation in the User Library fails.

It generally should be possible to get it work either way, but it isn’t worth the time to figure out if you have got it working one way now.