Compilation error on Rstan

Have to work with lots of error on Stan, this is what I got when compiling. Please help me to solve this:

**Error in file(con, "r") : cannot open the connection
In addition: Warning messages:
1: In system(cmd, intern = !verbose) :
  running command 'C:/PROGRA~1/R/R-40~1.2/bin/x64/R CMD SHLIB file2aa871844643.cpp 2> file2aa871844643.cpp.err.txt' had status 1
2: In file(con, "r") :
  cannot open file 'file2aa871844643.cpp.err.txt': No such file or directory
Error in sink(type = "output") : invalid connection**

If possible, add also code to simulate data or attach a (subset of) the dataset you work with.

Don’t forget to add relevant tags to your topic (top right of this form) especially for application area. Delete this text before posting your question :-) Thx!

If your question relates to installation please provide the following information:

  • Operating System
  • RStan Version
  • Output of writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars")))
  • Output of devtools::session_info("rstan")

If you are reporting a bug (thank you!) please use the issue tracker (github.com/stan-dev/rstan/issues) instead of the forums.

Looking forward to your topic!

We need to see the output of

example(stan_model, package = "rstan", run.dontrun = TRUE)

particularly the part under the line that says “Compilation argument”.

It gives me a long output. Last few lines of it:

SAMPLING FOR MODEL ‘73fc79f8b1915e8208c736914c86d1a1’ NOW (CHAIN 4).
Chain 4:
Chain 4: Gradient evaluation took 0 seconds
Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0 seconds.
Chain 4: Adjust your expectations accordingly!
Chain 4:
Chain 4:
Chain 4: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 4: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 4: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 4: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 4: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 4: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 4: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 4: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 4: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 4: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 4: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 4: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 4:
Chain 4: Elapsed Time: 0.011 seconds (Warm-up)
Chain 4: 0.014 seconds (Sampling)
Chain 4: 0.025 seconds (Total)
Chain 4:

After that, I complied my program again, but having the same error as earlier.

Error in file(con, “r”) : cannot open the connection
In addition: Warning messages:
1: In system(cmd, intern = !verbose) :
running command ‘C:/PROGRA~1/R/R-40~1.2/bin/x64/R CMD SHLIB file2c587e151aa4.cpp 2> file2c587e151aa4.cpp.err.txt’ had status 1
2: In file(con, “r”) :
cannot open file ‘file2c587e151aa4.cpp.err.txt’: No such file or directory
Error in sink(type = “output”) : invalid connection

Would like to know that why is this?

You you try your program but passing verbose = TRUE when you call stan or sampling?

Do you mean run like this?
stan(model_code=model, data= data_list, warmup = 500,
iter = 1000, chains = 2,verbose = TRUE)

Yes

Then, this error noticed,

Error in file(con, “r”) : cannot open the connection
In addition: Warning message:
In file(con, “r”) :
cannot open file ‘file2c581a232c8d.cpp.err.txt’: No such file or directory

There should be a lot more. Specifically, we are looking for the paragraphs following the line that says “Compilation argument”.

I think it would be an error of my model block.

Hi, I tried it in different ways, but failed,

Compilation argument:
C:/PROGRA~1/R/R-40~1.2/bin/x64/R CMD SHLIB file2c5813821819.cpp 2> file2c5813821819.cpp.err.txt

What is the part after the “Compilation argument” line? It should be similar to

Compilation argument: /home/ben/r-devel/bin/R CMD SHLIB file4a1a333174a.cpp 2> file4a1a333174a.cpp.err.txt g++-8 -std=gnu++14 -I"/home/ben/r-devel/include" -DNDEBUG -I"/home/ben/r-devel/library/Rcpp/include/" -I"/home/ben/r-devel/library/RcppEigen/include/" -I"/home/ben/r-devel/library/RcppEigen/include/unsupported" -I"/home/ben/r-devel/library/BH/include" -I"/home/ben/r-devel/library/StanHeaders/include/src/" -I"/home/ben/r-devel/library/StanHeaders/include/" -I"/home/ben/r-devel/library/RcppParallel/include/" -I"/home/ben/r-devel/library/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DBOOST_NO_AUTO_PTR -include '/home/ben/r-devel/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp' -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1 -I/usr/local/include -fpic -O3 -g0 -Wno-ignored-attributes -Wno-deprecated-declarations -Wno-unknown-pragmas -c file4a1a333174a.cpp -o file4a1a333174a.o

Like this,
Compilation argument:
C:/PROGRA~1/R/R-40~1.2/bin/x64/R CMD SHLIB file2c5817d021ca.cpp 2> file2c5817d021ca.cpp.err.txt
“C:/rtools40/mingw64/bin/“g++ -std=gnu++14 -I"C:/PROGRA~1/R/R-40~1.2/include” -DNDEBUG -I"C:/Users/erandi/Documents/R/win-library/4.0/Rcpp/include/” -I"C:/Users/erandi/Documents/R/win-library/4.0/RcppEigen/include/" -I"C:/Users/erandi/Documents/R/win-library/4.0/RcppEigen/include/unsupported" -I"C:/Users/erandi/Documents/R/win-library/4.0/BH/include" -I"C:/Users/erandi/Documents/R/win-library/4.0/StanHeaders/include/src/" -I"C:/Users/erandi/Documents/R/win-library/4.0/StanHeaders/include/" -I"C:/Users/erandi/Documents/R/win-library/4.0/rstan/include" -DEIGEN_NO_DEBUG -D_REENTRANT -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -include stan/math/prim/mat/fun/Eigen.hpp -std=c++1y -march=core2 -include C:/Users/erandi/Documents/R/win-library/4.0/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp -I “C:/Users/erandi/Documents/R/win-library/4.0/StanHeaders/include” -I “C:/Users/erandi/Documents/R/win-library/4.0/RcppEigen/include” -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c file2c5817d021ca.cpp -o file2c5817d021ca.o
file2c5817d021ca.cpp:6:36: warning: ISO C++11 requires whitespace after the macro name
#define STAN__SERVICES__COMMAND_HPP#include <boost/integer/integer_log2.hpp>

Do you have any idea about

file2c585b18381.cpp:375:1452: note: cannot convert ‘stan::math::array_builder::array() with T = stan::math::var’ (type ‘std::vectorstan::math::var’) to type ‘const std::vector&’

This is a part of error what I got earlier.